Boost logo

Boost Users :

Subject: Re: [Boost-users] [tuple][mpl][fusion] How to " prune" or " collapse" a tuple?
From: Christopher Schmidt (mr.chr.schmidt_at_[hidden])
Date: 2010-08-14 19:59:23


AJG schrieb:
> Steven Watanabe <watanabesj <at> gmail.com> writes:
>> Try using fusion::remove
>> http://www.boost.org/libs/fusion/doc/html/fusion
>> /algorithm/transformation/functions/remove.html
>>
>
> Thanks! That function seems to do exactly what I need. However,
> is it expected to work using boost::tuples? (I tried using
> fusion::vectors and it works perfectly.)
>
> The issue I'm running into is that remove() returns a filter_view,
> which, I'm guessing, is convertible to a fusion::vector but not to
> a boost::tuple. Is there any way to make that latter conversion work?
>
> I've already included:
>
> #include <boost/fusion/include/remove.hpp>
> #include <boost/fusion/adapted/boost_tuple.hpp>
>
> But it looks like boost::tuple isn't being adapted fully.

Including /fusion/adapted/boost_tuple.hpp just transforms any
boost::tuple into an implementation of the random access sequence concept

http://www.boost.org/doc/libs/1_43_0/libs/fusion/doc/html/fusion/sequence/concepts/random_access_sequence.html

i.e. all boost::tuple instantiations go along with fusion's intrinsic
sequence functions.

To construct a tuple from a fusion sequence, you should stick to the
fusion container. For example:

#include <boost/fusion/container/vector.hpp>
#include <boost/fusion/algorithm/transformation/remove.hpp>

struct E{};

int main()
{
        using namespace boost::fusion;

        typedef vector<E, int, E, double, E, char, E> vec;
        typedef result_of::as_vector<
                result_of::remove<vec, E>::type
>::type fvec;

        fvec f(0, 1.0, 'c');
}

-Christopher


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