Which is exactly what I was hinting at that member functions (or free functions) are less error-prone than algorithms and you should be preferred when possible.
Nonsense. See the bit about this in the middle of my post. A programmer isn't more likely to use any alternative correctly. Implementing a large number of decorations, even templates, only changes how they will use it incorrectly. It is always possible to use a method as an interface--to the limits of your compiler; so, where do you draw the line?
Even the function provided by anon is not an alternative for 'std::sort'. It allows for only a very small sample of the functionality.
Most likely, I would try to encapsulate std::sort via different member functions in objects, yes.
So, you would call this method based on the anon decoration 'lexicographic_sort'.
What do you name this function:
Code:
sort(r.begin(), r.end(), _1(&type::accessor1) < _2(&type::accessor1));
What about this one:
Code:
sort(r.begin(), r.end(), _1(&type::accessor2) > _2(&type::accessor3));
It goes on and on... And according to you inheritance should be preferred so that this too is a method:
Code:
sort(r.begin(), r.end(), _1(&type::accessor3) < _2(&type::accessor3));
Because it gives the illusion or whatever you want to call it that the object is sorting itself.
^_^
Well, that was interesting.
Soma
http://cboard.cprogramming.com/showp...&postcount=105