Mark Ruzon wrote:
Assume we have a range of objects of type tuple
and a function object that compares two objects of type T1. How would a person sort this range using this function object and bind? I want something along the lines of: std::sort(first, last, boost::bind<bool>(comp, boost::bind(boost::get<0>, _1), boost::bind(boost::get<0>, _2)));
but this isn't remotely close to compiling. I could create a custom function object, but I'd rather learn how to use bind properly.
A very inconvenient question. :-)
In principle, when you want to use bind with a function template:
template <typename T> int f( T const & x);
you supply its template parameters when binding it:
bind( f<int>, _1 );
When you have several overloads:
template <typename T> int f(const type1<T>& x);
template <typename T> int f(const type2<T>& x);
you cast it to the correct type or use a function pointer:
int (*pf)( const type2<int>& ) = &f;
bind( pf, _1 );
Going by this logic:
T1 const & (*get0)( tuple