There's no way to determine the size of an array given just a pointer to it. You could either pass the size as a separate argument:
CallbackSelector(std::pair<Arg, Callback> mapping[], size_t size) :
Mapping(mapping, mapping + size)
or infer it as a template parameter:
template <size_t size>
CallbackSelector(std::pair<Arg, Callback> (&mapping)[size]) :
Mapping(mapping, mapping + size)
or, in C++11 or later, you could take an initializer_list
argument
CallbackSelector(std::initializer_list<std::pair<Arg, Callback>> mapping) :
Mapping(mapping.begin(), mapping.end())
// Usage example
CallbackSelector<std::string, boost::function<void(void)> > selector {
{arg1, callback1},
{arg2, callback2}
};
(Note: I took the liberty of renaming _Mapping
, a reserved name that you shouldn't have been using).