In my continuing effort to demonstrate my inability to get much of anything
working with the MPL, I'm having trouble inserting a type into an existing set
of types. The code compiles and runs, but the revised type sequence is empty.
Here's the code:
#include
#include
#include <typeinfo>
#include <iostream>
namespace mpl = boost::mpl;
struct Base { virtual ~Base(){} };
struct A { virtual ~A(){} };
struct B { virtual ~B(){} };
struct Print {
template<typename T>
void operator()(const T&)
{
std::cout << typeid(T).name() << ", ";
}
};
int main()
{
typedef mpl::set Constraints;
// print contents of Constraints (should be the equivalent
// of "[A, B,]")
std::cout << '[';
mpl::for_each<Constraints>(Print());
std::cout << "]\n";
// add Base to Constraints, call result BaseClasses
typedef mpl::insert BaseClasses;
// print contents of BaseClasses (should be the equivalent
// of "[A, B, Base, ]")
std::cout << '[';
mpl::for_each<BaseClasses>(Print());
std::cout << "]\n";
}
Can anybody spot what I'm doing wrong? I know that I could use the two-argument
form of insert with a set, but I'm trying to write code that will work with a
vector, too, and at any rate, I get the same results with the two-argument form
of set.
Thanks,
Scott