I\'m trying to implement a container class for different functions where I can hold function pointers and use it to call those functions later. I\'ll try to discribe my problem
You may do something like:
class BaseFunc {
public:
virtual ~BaseFunc() = default;
virtual void Call(std::vector>& args_vec) const = 0;
};
template class Function;
template class Function : public BaseFunc
{
public:
Function(R (*f)(Args...)) : f(f) {}
void Call(std::vector>& args_vec) const override
{
Call(args_vec, std::index_sequence_for());
}
private:
template
void Call(
std::vector>& args_vec,
std::index_sequence) const
{
// Add additional check here if you want.
f(boost::get(args_vec.at(Is))...);
}
private:
R (*f)(Args...);
};
Live example