Boost logo

Boost Users :

Subject: Re: [Boost-users] [lambda] std::sort problem
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-01-24 19:30:46


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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net