Boost logo

Boost :

Subject: Re: [boost] [fusion] flatten/flatten_view Proposal
From: Eric Niebler (eniebler_at_[hidden])
Date: 2013-10-23 15:22:08


On 10/23/2013 7:30 AM, TONGARI J wrote:
> Hi there,
>
> I've created the ticket, doc&test included
> https://svn.boost.org/trac/boost/ticket/9294
>
> 'flatten' is an algorithm which returns a view that allows you to go
> through the leaf elems sequentially.
>
> For example:
>
> flatten(make_vector(1, make_vector(2, 3))) == make_vector(1, 2, 3)
>
> This is developed when I use Fusion to work with SQL for simple data
> mapping.

You have duplicated a *huge* amount of work already in Fusion for
supporting segmented sequences. If your Fusion sequence is logically a
sequence of sequences, you just have to implement
extension::is_segmented_impl and extension::segments_impl to make your
type a valid Fusion sequence that has "flat" Fusion iterators.
extension::segments_impl just has to return a Fusion sequence of Fusion
sequences. See libs/fusion/test/sequence/tree.hpp for an example.

Sorry this isn't documented. That's my fault. I'm doubly sorry that you
went to the trouble of implementing this. Adding support to Fusion for
segmented sequences is one of the reasons why I have no hair today. ;-)

-- 
Eric Niebler
Boost.org
http://www.boost.org

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