Boost logo

Boost Users :

Subject: Re: [Boost-users] Using lamdba for vector of array initialization
From: Thomas Heller (thom.heller_at_[hidden])
Date: 2011-06-09 03:15:45


On Thu, Jun 9, 2011 at 8:30 AM, Alexander Khomyak
<Alexander.Khomyak_at_[hidden]> wrote:
> Hi.
> I have vector of boost array:
>
> typedef boost::array<char, 10> array10;
> typedef std::vector<array10> vector_of_array10;
> vector_of_array10 v;
> v.resize(10);
>
> Now I initialize it using for statement:
>
> for(vector_of_array10::iterator i = v.begin(); i != v.end(); ++i)
>       (*i)[0] = '\0';

Using Boost.Phoenix (to be released with 1.47, already on trunk):
#include <boost/phoenix.hpp>

using boost::phoenix::placeholders::_1;
std::for_each(v.begin(), v.end(), _1[0] = '\0');

> How can I do the same initialization using lambda expression and for_each?
> In advance thank you very much for the tip.

HTH,
Thomas


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