#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;
};

template <class T>
struct colortypes
{
    typedef T::colortypes type;
};

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
      , mpl::contains<
             colortypes<mpl::_>
           , integral_c<colors,green>
        >
    >::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;
}




