Subject: Re: [boost] [fusion] mpl::clear doesn't work on fusion views
From: Joel de Guzman (joel_at_[hidden])
Date: 2011-07-30 06:16:26
On 7/30/2011 3:52 AM, Eric Niebler wrote:
> Today I ran into a limitation in Fusion/MPL interoperability. I couldn't
> use an mpl algorithm on a Fusion sequence because mpl::clear wasn't
> defined on it. The sequence was a joint_view. I see that
> fusion::detail::clear is only defined for Fusion cons, map, set, vector
> and deque. Can we get it defined for all Fusion sequences? I think for
> everything else, an empty Fusion vector would do. That is all
> fusion::clear does, btw.
One major difference between MPL and Fusion is that operations
like these in MPL preserve the original sequence type. E.g. clearing
an mpl::vector will give you an empty mpl::vector. That is why
it is only defined for those containers you mentioned. Clearly,
clearing a joint_view will not be a sequence-type preserving operation.
In the same vein all MPL 'views' cannot be cleared. Try mpl::clear on
an mpl view, for example.
> (Aside: it seems strange to me that mpl::clear of a fusion::set gives an
> empty set, but that fusion::clear of an empty set gives an empty vector.
> This should probably be made consistent.)
OK. It's been a while since I've touched the code. Feel free to commit
a patch. It looks like bug.
-- Joel de Guzman http://www.boostpro.com http://boost-spirit.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk