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
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
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
, mpl::integral_c
, mpl::integral_c
colorcoll1;
typedef mpl::vector<
mpl::integral_c
, mpl::integral_c
colorcoll2;
typedef mpl::vector<
mpl::integral_c
colorcoll3;
typedef mpl::vector 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::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 intColl;
std::cout << mpl::size<intColl>::value << std::endl;
typedef mpl::copy_if > >::type
newIntColl;
std::cout << mpl::size<newIntColl>::value << std::endl;
}
int main()
{
func();
return 0;
}