10 #ifndef META_UTIL_FACTORY_H_
11 #define META_UTIL_FACTORY_H_
15 #include <unordered_map>
26 template <
class DerivedFactory,
class Type,
class... Arguments>
41 using std::runtime_error::runtime_error;
48 inline static DerivedFactory&
get()
60 template <
class Function>
64 throw exception{
"classifier already registered with that id"};
65 methods_.emplace(identifier, std::forward<Function>(fn));
75 template <
class... Args>
79 throw exception{
"unrecognized identifier"};
80 return methods_[identifier](std::forward<Args>(args)...);
85 std::unordered_map<std::string, factory_method>
methods_;