2

In the C++ book, I have met next function:

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& ?

ceth
  • 44,198
  • 62
  • 180
  • 289

0 Answers0