Topic: Size argument to count/count_if
Author: law@solution-frameworks.com
Date: 1995/10/06 Raw View
I have a question about the nature of the final argument to
the count and count_if algorithms. Must this argument
support post-increment, operator +=, operator + and assigment,
or something else?
More precisely, the public-domain HP implementation of count()
is:
template < class InputIterator, class T, class Size >
void count( InputIterator first, InputIterator last,
const T &value, Size &n ) {
while ( first != last )
if ( *first++ == value ) n++;
}
Why couldn't the interesting expression be any of:
n += 1
n -= -1
n = n + 1
etc?
The WP doesn't seem to provide sufficient guidance (or else
I couldn't find it).
Bill Law
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]