Boost logo

Boost Users :

Subject: Re: [Boost-users] [mpl][fusion] How to transform vector_c into std::vector?
From: Mostafa (mostafa_working_away_at_[hidden])
Date: 2013-11-29 04:13:35


On Thu, 28 Nov 2013 11:21:42 -0800, Larry Evans
<cppljevans_at_[hidden]> wrote:

> On 11/28/13 00:37, Mostafa wrote:
>> On Wed, 27 Nov 2013 21:09:04 -0800, TONGARI J <tongari95_at_[hidden]>
>> wrote:
>>
>>> 2013/11/28 Mostafa <mostafa_working_away_at_[hidden]>
>>>
>>>> How does one transform an mpl:vector_c into a regular std::vector?
>>>>
>>>> Sample input:
>>>>
>>>> typedef mpl::vector<int, int_<10>, int_<11>, int_<12> > some_vector_c;
>>>>
>>>
>>> Perhaps:
>>>
>>> std::vector<int> v;
>>> fusion::for_each(some_vector_c(), [&v](int val){v.push_back(val);});
>>
>> Thanks, I ended up using mpl's for_each. Even though I don't quite
>> understand how it works. Specifically, what does boost::get do? I
>> couldn't find any documentation on it.
> See it's definition here:
>
> http://www.boost.org/doc/libs/1_55_0/libs/utility/value_init.htm
>
> The mpl for_each doc would be clearer if:
>
> typedef begin<Sequence>::type i1;
> value_initialized< deref<i1>::type > x1;
> f(boost::get(x1));
>
> were replaced with:
>
> typedef begin<Sequence>::type i1;
> value_initialized< deref<i1>::type > x1;
> f(x1.data());
>
> then there would be no chance about which get was being used.
>
> -Larry

Thanks. It seems get is used because it's recommended practice. See the
section "Recommended practice: The non-member get() idiom". It would have
been quite helpful if the mpl doc linked to this section of the value_init
doc.

Mostafa


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