I have defied a range and I need to find the number of elements in it. My current code is
size_t c = 0;
for(auto elem : range){
c++;
}
return c;
However, the compiler is whining about the unused variable elem and I can't get rid of it. I though of using something like
std::count_if(range.begin(), range.end(), [](type elem){return ture;});
But I feel it is an overkill and it does not seem right.
I am wondering if there is a nicer systematic way of achieving this without defining an extra variable?