Boost logo

Boost Users :

Subject: Re: [Boost-users] [Fusion] Flatten a sequence of sequences
From: Joel de Guzman (joel_at_[hidden])
Date: 2010-12-07 18:47:56


On 12/8/2010 1:25 AM, TONGARI wrote:
> 2010/12/7, Clinton Mead<clintonmead_at_[hidden]>:
>> Hi All
>>
>> Lets say I have something like the following:
>>
>> make_vector(1, make_vector('b', 3, make_vector(4, 5.5), "six"), 7, 8)
>>
>> I want to produce an function f such that
>>
>> f(make_vector(1, make_vector('b', 3, make_vector(4, 5.5), "six"), 7, 8)) ->
>> [1,'b',3,4,5.5,"six",7,8]
>>
>> i.e. a flattened version of the sequence.
>
> Hmmm...not sure if there's already something for that.
> Just after seeing your post, I gave it a try to implement it (see attachment),
> but there's a problem in this implementation that needs to hack into
> Fusion code (not knowing where am I doing wrong). If you want it
> compiled, comment away line 39 in<boost/fusion/iterator/distance.hpp>

You don't need to hack into Fusion. Fold is your friend. Use
fold to accumulate the result into a joint_view.

Regards,

-- 
Joel de Guzman
http://www.boostpro.com
http://spirit.sf.net

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