44#ifndef MULTI_INVOKE_HPP
45#define MULTI_INVOKE_HPP
55template<
typename key,
typename... function_args>
class multi_invoke
58 typedef void (*callback_type_t)(function_args...);
65 void operator()(key k, function_args... args)
const
67 std::vector<callback_type_t> funcs;
69 auto range = callbacks.equal_range(k);
72 for (
auto i = range.first; i != range.second; i++) {
73 funcs.push_back((*i).second);
75 for (
auto cb: funcs) {
86 void add(key k, callback_type_t cb)
89 auto range = callbacks.equal_range(k);
90 for (
auto it = range.first; it != range.second; ++it) {
91 if (it->second == cb) {
96 callbacks.insert(std::make_pair(k, cb));
105 void remove(key k, callback_type_t cb)
107 auto range = callbacks.equal_range(k);
108 for (
auto it = range.first; it != range.second; ++it) {
109 if (it->second == cb) {
123 bool contains(key k)
const
125 return callbacks.count(k) > 0;
152 return callbacks.empty();
156 std::multimap<key, callback_type_t> callbacks;