Biorąc poniższy przykład, zastanawiam się, czy istnieje alternatywa dla boost::mpl::for_each
, która wywołuje funkcję Functor bez żadnych argumentów.boost :: mpl :: for_each bez tworzenia instancji
#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());
Wygląda na to, że for_each
jest domyślną instancją typów.
Dzięki, działa jak czar :) – abergmeier