I try to define a "sortby" method that would sort a list using any member
function that fits some constraints (taking no parms, returning a result
that can be compared using the > operator and being const)
I wrote this:
template <class T>
class mylist:public std::list<T>
{ // ...
template
struct cmp: public std::binary_function
{
bool operator()(const T& f1, const T& f2) {return (f1.F)() > (f2.F)();};
};
template
bool sortby(R (T2::*F)() const)
{
sort(cmp());
return true;
};
}; // class mylist
using VC6 (I know...) I get these 3 errors:
algos.h(356) : error C2440: 'specialization' : cannot convert from 'double
(__thiscall cadoo::cadFace::*)(void) const' to 'double (__thiscall
cadoo::cadFace::*)(void)'
algos.h(356) : error C2975: 'cmp' : invalid template argument for 'F',
constant expression expected
algos.h(356) : error C2514: 'dyl::List<class cadoo::cadFace>::cmp' : class has no constructors
any idea ? I also checked boost.org for help on functors, lambda ... but
could not figure out how to use them simply for my application.
thanks!
Philippe Guglielmetti