|
Boost : |
Subject: Re: [boost] howto: boost.lambda + stl on VS 2010 (SP1) ?
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2011-05-09 03:16:33
On 05/05/2011 01:37, Raffi Enficiaud wrote:
> Hi all,
>
> Sorry for bothering with this. I recently encountered some problems in using
> boost.lambda with Visual 2010 Express, and need some clues for solving the
> issue (there are many ways around of course).
> I simply want to accumulate the values of a std::map, and I thought using
> lambda to access the second member of the map iterator was appropriate. Here
> is the piece of code:
>
> typedef std::map<T1, unsigned short> m_t;
> m_t m ; // fill m
> double acc(0);
> std::for_each(m.begin(), m.end(), var(acc) +=& _1->*&
> m_t::value_type::second);
>
> The last line does not compile on Visual (it does on GCC), I have to add a
> typedef:
>
> typedef typename m_t::value_type aa;
> std::for_each(m.begin(), m.end(), var(acc) +=& _1->*& aa::second);
>
> Which one is "more correct" ?
It's one of the annoying MSVC bugs.
MSVC doesn't like it when you chain nested names in template contexts.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk