boost-mpl

How to use boost::mpl to compose policies?

I have used something like the following to compose policies for my application: The policy classes look like this: struct Policy { static void init(); static void cleanup(); //... }; template <class CarT, class CdrT> struct Cons { static void init() { CarT::init(); CdrT::init(); } static void cleanup() { CdrT:...

using boost::mpl::bitor_

I have a class that accepts a list of policy classes using boost::mpl. Each policy class contains an identifying tag. I would like MyClass to produce the OR-ed result of each policy class' identifying tag. Unfortunately, I'm having some trouble figuring out how to correctly use the boost::mpl::fold<> functionality. If anybody can help, I...

How do I invoke a non-default constructor for each inherited type from a type list?

I'm using a boost typelist to implement the policy pattern in the following manner. using namespace boost::mpl; template <typename PolicyTypeList = boost::mpl::vector<> > class Host : public inherit_linearly<PolicyTypeList, inherit<_1, _2> >::type { public: Host() : m_expensiveType(/* ... */) { } private: const ExpensiveType m...

Sun C++ Compilers and Boost

I am currently developing on OpenSolaris 2009-06. The Boost::MPL Documentation seems to suggest that sun compilers are not supported (the document was last updated in 2004 ). Boost's top level documentation seems to suggest that the sun compilers 5.10 onwards are supported -- I guess this is a general level of support or does this includ...

Templating off of an arbitirary-length list of types in C++

Here's what I want to be able to type: class foo : public watchKeys<A, B, C> {}; //Or any list of keys Boost::mpl has sequences, which allow you to do this, but I don't want to have to do: class foo : public watchKeys<mpl::list<A, B, C> > {}; I don't mind it being "ugly" or verbose on the inside, but I want the way watchKeys is ult...

How to loop through a boost::mpl::list?

This is as far as I've gotten, #include <boost/mpl/list.hpp> #include <algorithm> namespace mpl = boost::mpl; class RunAround {}; class HopUpAndDown {}; class Sleep {}; template<typename Instructions> int doThis(); template<> int doThis<RunAround>() { /* run run run.. */ return 3; } template<> int doThis<HopUpAndDown>() { /* hop ho...

How to apply an mpl::transform to an mpl::string?

Hi, I'm trying to apply a transformation to an mpl::string, but can't get it to compile. I'm using MS VC++2010 and Boost 1.43.0. The code: #include <boost/mpl/string.hpp> #include <boost/mpl/vector_c.hpp> #include <boost/mpl/transform.hpp> #include <boost/mpl/plus.hpp> #include <boost/mpl/arithmetic.hpp> using namespace boost; int ma...

Using boost::mpl::lambda to remove types from a boost::mpl::list based on static const member variable

I have a list of types defined as: typedef boost::mpl::list<Apple, Pear, Brick> OriginalList; I would like to create a second list that does not contain any fruit, i.e. the resultant list formed from the first list would contain a single type Brick. Fruit is identified through a static const variable defined within the types, e.g.: s...

Combination of types using boost::mpl

I have a list of types, from which I want to construct the list of all combinations with two elements. For example: namespace mpl = boost::mpl; typedef mpl::vector<int, long> typelist; // mpl magic... // the wanted list is equivalent to: typedef mpl::vector<pair<int, int>, pair<int, long>, pair<long, int>, pair<long,...