Boost logo

Boost Users :

Subject: Re: [Boost-users] Using lambda expressions in stl algorithms
From: Stuart Dootson (stuart.dootson_at_[hidden])
Date: 2010-12-14 10:13:00


On Tue, Dec 14, 2010 at 2:49 PM, <przemyslaw.sliwa_at_[hidden]> wrote:
>
> Hello,
>
> Could someone tell me why this code does not compile? Can it be modified in
> order to compile?
>
>         struct CcyCplEventKey
>         {
>                 CurrencyCouple        CcyCpl;
>                 EventType                Event;
>         }
>
>         typedef std::map<CurrencyEventKey, CurrencyEventPtr> mapType;
>
>         mapType ccyOut;
>
>         std::for_each(ccyOut.begin(), ccyOut.end(),
> (&*boost::lambda::_1)->*&CcyCplEventKey::Event);
>
> Cheers

Ummm - for a start, a std::map iterator references a std::pair
containing the key and value for that map entry, so you need to get
hold of the 'first' member of the std::pair to use the key. Without
type definitions for EventType, CurrencyEventPtr and CurrencyCouple,
it's difficult to go further than that...

Stuart Dootson


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