C++ has many algorithms in the form:
Take, for example:Code:algo_if ( iterator, iterator, unary_function_object );
This is all well and good if myContainer contains ints, but what if it contained strings?Code:algo_if (myContainer.begin(), myContainer.end(), bind1st (equal_to<size_t> (), 7))
equal_to, or perhaps algo_if, implicitly passes in myContainer.begin() as the first element for comparison, then myContainer.begin()+1, etc.
What if I didn't want to pass in the element of a container...what if I wanted to pass in the string length of each element?!
I have at my disposal strlen, which takes a string argument...
and length, which takes no argument other than the implicit this.



LinkBack URL
About LinkBacks


