Changed this:
template <typename... Args>
void operator()(Args... args) {
if (ptr)
static_cast<B<Args...>*>(ptr)->function(std::forward<Args...>(args...));
}
To this:
template <typename... Args>
void operator()(Args&&... args) {
if (ptr)
static_cast<B<Args...>*>(ptr)->function(std::forward<Args>(args)...);
}
Looks like its working correctly