通用计数功能

在C ++书中,我遇到了下一个功能:

template<class Container>
int count(const Container& container) {
    int sum = 0;
    for(auto&& elt : container) {
        sum += 1;
    }
    return sum;
}

I am just wondering why we use here reference to reference auto&& instead of just reference auto& ?

评论