
From: przemyslaw.sliwa@uk.bnpparibas.com
<snip>
In order to sort the objects in the set I have to use the functor
struct lessThan : public std::binary_function, boost::shared_ptr, bool> { bool operator ()(const boost::shared_ptr &lhs, const boost::shared_ptr &rhs) const { return (*lhs) < (*rhs); } };
This is quite long and I believe boost can shorten it a lot. I have tried it with boost::lamba and boost::bind but could not make it working. Basically I would like to eliminate the need of writing the definition of struct lessThan. Could someone help me with that?
You could write one class that works for all types:
struct indirectLessThan
{
template <typename PtrT>
bool operator()(PtrT a, PtrT b)
{
return *a < *b;
}
};
And use it like this:
typedef std::set