Matthias Kaeppler
Consider this code:
vector<int> coll; // ... push back some values vector
ptrcoll; // ... push back pointers to the values of coll indirect_iterator< vector
::iterator > begin(ptrcoll.begin()),
Careful; vector iterators are not neccessarily pointers.
end(ptrcoll.end());
sort( begin, end, less<int> );
--
My question: After the sort statement, coll is sorted, right? (and ptrcoll is not). However, I need to sort a vector of pointers according to a predicate which applies to non-pointers. In this case, I want to sort ptrcoll, according to the less-relation on the pointees in coll.
How can I achieve that?
struct indirect_less
{
template <class It>
bool operator()(It i1, It i2) const
{
typedef typename std::iterator_traits<It>::value_type value_type;
return std::less