Boost logo

Boost Users :

From: Christian Holmquist (c.holmquist_at_[hidden])
Date: 2007-05-30 04:37:46


Hello,

I'm trying to create a fusion::filter_view with a predicate that must
access, for each element, the element at the same position in an 'external'
typelist.

Let's say I have two sequences like this

typedef mpl::vector<int&> mpl_vec;
typedef fusion::vector<int> f_vec;

Now, I would like a view into f_vec of, for instances, all references in
mpl_vec.

typedef fusion::filter_view<f_vec, is_reference<mpl::_> > f_view;
This is obviously wrong; is_reference should evaluate with mpl_vec as its
source.

If I wrap is_reference like this

template<class Sequence>
struct is_reference_in
{
    template<class T>
    struct apply : boost::is_reference<T> // Wrong, T should be extracted
from Sequence
    {

    };
};

and create the view like
typedef fusion::filter_view<f_vec, is_reference_in<mpl_vec> > f_view2;
I gain access to the mpl_vec in my predicate, but since the predicate is
immutable I cannot iterate over the Sequence template parameter to extract
the type to send to is_reference.

The way i'm solving this now is to store everything in the same vector, like
typedef fusion::vector<fusion::pair<int, int&> > f_vec
and create predicates that work with fusion::pair instead. This seems
clumsy.

Could zip_view help me out here?
Any other suggestions?

Thanks,
Christian



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