In the following class, wrapper
takes a pointer to an arbitrary const
method and returns the result of a call to that method with const
re
You can perfect forward the arguments to the function:
template<typename T, typename... Ts, typename... Args>
auto& wrapper(T const& (C::*f)(Ts...) const, Args&&... args) {
return const_cast<T&>((this->*f)(std::forward<Args>(args)...));
}
This is achieved by making args
a forwarding reference parameter pack. Note that we need to introduce a new Args
template parameter pack in order to deduce the arguments correctly.