19 Jun
2013
19 Jun
'13
10:39 a.m.
I wonder what is the recommended way to count the elements in a filtered range. Let range be a random access range, and filter the result of filtered(predicate), auto filtered_range = range | filter; count_if( filtered_range, [](const&){ return true; }); // (& omitted in lambda) counts the elements in a filtered range. _If_ this is the best way to count the elements in a filtered range, what about defining Range boost::count(Range&& r); to count all element in the range? It could call size() if available and count_if otherwise. Bests, Gonzalo BG