Created
December 23, 2009 10:46
-
-
Save mashiro/262462 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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