Boost logo

Boost :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2004-10-10 12:57:13


David Abrahams writes:
> "Peter Dimov" <pdimov_at_[hidden]> writes:
>
>> David Abrahams wrote:
>>> Terje Slettebø <tslettebo_at_[hidden]> writes:
>>>
>>>> // int_vector r_list = to_runtime<c_list>();
>>>>
>>>> int_vector r_list;
>>>>
>>>> boost::mpl::for_each<c_list>(to_sequence<int_vector>(r_list));
>>>
>>> Better yet:
>>>
>>> int_vector r_list;
>>> boost::mpl::for_each<c_list>(std::back_inserter(r_list));
>>>
>>> Enjoy ;-)
>>
>> Um, how does this work? back_inserter returns an iterator, not a
>> function object; is there some magic in mpl::for_each that I can't
>> see? Maybe I'm looking at the wrong version?
>
> No, I'm just an idiot :(.
> Please ignore my post.

This should work, though:

    int_vector r_list;
    boost::mpl::for_each<c_list>( boost::bind(&int_vector::push_back, &r_list, _1) );

-- 
Aleksey Gurtovoy
MetaCommunications Engineering

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk