
25 Jan
2009
25 Jan
'09
12:30 a.m.
AMDG MichaĆ Nowotka wrote:
Following code does not compile:
sort(m_results->begin(), m_results->end(), lambda::_1->second > lambda::_2->second);
where:
m_result is type of std::vector<std::pair<const SomeClass*,double>* >
vs2008 compiler says:
error C2780: 'void std::sort(_RanIt,_RanIt)' : expects 2 arguments - 3 provided, see declaration of 'std::sort'
but in lamda documentation there is similar example:
sort(vp.begin(), vp.end(), *_1 > *_2);
so what's wrong with my code
Boost.Lambda doesn't overload operator-> because C++ doesn't allow it to work in general. You have to do it like this (lambda::_1->*&std::pair<const SomeClass*,double*>::second) using member pointers. In Christ, Steven Watanabe