Hi,

I have a mpl::vector of types.  Each of the types in the vector have
themselves another nested mpl::vector that is a sequence of enums.  I have
include the code below.

What I am trying to do is take the original sequence and make a new sequence
based on the predicate that only elements with certains enums in their
nested vector be included in the new sequence.  I have included more notes
in the embedded comments.

I was thinking of using mpl::copy_if but am having trouble getting the
predicate right.

Wanted to know if anyone could steer me in the right direction.  I am trying
to fill in the ??? below.  I am having trouble writing a custom predicate.

Thanks in advance.

Regards,

Bruce

#include <string>

#include <iostream>

#include <boost/mpl/vector.hpp>

#include <boost/mpl/begin_end.hpp>

#include <boost/mpl/deref.hpp>

#include <boost/mpl/count_if.hpp>

#include <boost/mpl/size.hpp>

#include <boost/mpl/for_each.hpp>

#include <boost/type_traits/is_member_pointer.hpp>

#include <boost/mpl/vector_c.hpp>

#include <boost/mpl/copy_if.hpp>

#include <boost/mpl/less.hpp>

#include <boost/mpl/placeholders.hpp>

#include <boost/mpl/find.hpp>



namespace mpl = boost::mpl;

using namespace mpl::placeholders;

enum colors

{

red,

blue,

green,

yellow

};

template<typename COLORTYPES>

struct TestClass

{

typedef COLORTYPES colortypes;

};

void func()

{

// come up with a interface to simplify this like vector_c - only it must be
able to handle enums - I would think one would already exist

typedef mpl::vector<

mpl::integral_c<colors,red>

, mpl::integral_c<colors,green>

, mpl::integral_c<colors,blue>

> colorcoll1;

typedef mpl::vector<

mpl::integral_c<colors,red>

, mpl::integral_c<colors,blue>

> colorcoll2;



typedef mpl::vector<

mpl::integral_c<colors,green>

> colorcoll3;



typedef mpl::vector<TestClass<colorcoll1>, TestClass<colorcoll2>,
TestClass<colorcoll3> > testvector;

std::cout << " SIZE IS " << mpl::size<testvector>::value << std::endl;

// would like to make a new vector from testvector that contains only those
types that have green in their nested vector colortypes.

//In other words, go from testvector which has three types to a vector that
only has TestClass<colorcoll1> and TestClass<colorcoll3>

// typedef mpl::copy_if<testvector, ???? >::type testvectorwithgreen;



// I can do it successfully when operating directly on the container as
below, but am having trouble deterimining the predicate for the above case

typedef mpl::vector_c<int, 1,2,3,4,5,6,7,8> intColl;


std::cout << mpl::size<intColl>::value << std::endl;

typedef mpl::copy_if<intColl, mpl::less<mpl::_1, mpl::int_<5> > >::type
newIntColl;



std::cout << mpl::size<newIntColl>::value << std::endl;

}

int main()

{

func();

return 0;

}