added generic multimethod implementation
[ozulis.git] / src / core / multimethod.hh
blobc3aca1b430f6f1a3b7042e7a296d81f81c9e9d5a
1 #ifndef CORE_MULTIMETHOD_HH
2 # define CORE_MULTIMETHOD_HH
4 # include <map>
5 # include <tr1/tuple>
6 # include <core/assert.hh>
8 namespace core
10 template<typename Value, typename ...Keys>
11 class DispatchTable
13 public:
14 void addEntry(Value value, Keys... keys);
15 Value& dispatch(Keys... keys);
17 protected:
18 typedef std::tr1::tuple<Keys...> key_t;
19 std::map<key_t, Value> table_;
23 # include "multimethod.hxx"
25 #endif /* !CORE_MULTIMETHOD_HH */