Skip to content

Instantly share code, notes, and snippets.

@mashiro
Created December 23, 2009 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mashiro/262462 to your computer and use it in GitHub Desktop.
Save mashiro/262462 to your computer and use it in GitHub Desktop.
#include <boost/mpl/vector.hpp>
#include <boost/mpl/for_each.hpp>
#include <iostream>
struct register_type
{
typedef boost::mpl::vector<> type;
template <typename T>
struct push_back
{
// retypedef register_type::type
// boost::mpl::push_back<register_type::type, T>;
};
};
class foo
{
public:
typedef register_type::push_back<foo> _registered;
static void f() { std::cout << "foo" << std::endl; }
};
class bar
{
public:
typedef register_type::push_back<bar> _registered;
static void f() { std::cout << "bar" << std::endl; }
};
struct call_f
{
template <typename T>
void operator ()(T) const
{
T::f();
}
};
int main()
{
boost::mpl::for_each<register_type::type>(call_f());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment