Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template <typename R>
- class MultiFuncObject
- {
- unordered_map<type_index, void(*)()> m_funcs;
- public:
- template <typename ...A1>
- MultiFuncObject<R> operator +=(R(*f)(A1...))
- {
- m_funcs[typeid(R(A1...))] = (void(*)()) f;
- return *this;
- }
- template <typename ...A1>
- R operator()(A1... a1) const
- {
- unordered_map<type_index, void(*)()>::const_iterator it = m_funcs.find(typeid(R(A1...)));
- if (it != m_funcs.end())
- {
- R(*f)(A1...) = (R(*)(A1...))(it->second);
- (*f)(a1...);
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement