以下面的例子,我想知道是否有替代boost::mpl::for_each
,它沒有任何參數調用Functor。boost :: mpl :: for_each沒有實例化
#include <boost/mpl/vector.hpp>
#include <boost/mpl/for_each.hpp>
struct EasyFixEngineA { static const char* const name() { return "a"; } };
struct EasyFixEngineB { static const char* const name() { return "b"; } };
struct Registrator {
// Would prefer a template<class T> void operator()()
template<class T> void operator()(T t) {
RegisterInFactory<EasyFixEngine, T> dummy(T::name());
}
};
// ...
typedef boost::mpl::vector<EasyFixEngineA,EasyFixEngineB> Engines;
boost::mpl::for_each<Engines>(Registrator());
好像for_each
是默認實例化的類型。
謝謝,像魅力:) – abergmeier