I am writing a template class that wraps around member functions to reduce some calls - if some condition is true, the member function doesn't need to be called. The signature would look something like this
template <typename MemFuncType, MemFuncType> class MemberWrapper;
And I can specialize it thus:
template <typename R, typename T, R T::* MemFunc> class MemberWrapper<R T::*, MemFunc>{};
I would also like to restrict the number of arguments of R T::*
. How do I do this?
The only solution I can think of is to implement a member functions traits class by providing partial specializations based on return type, function type, arguments list and cv-qualifiers. This would lead to a cumbersome implementation like the current std::mem_fn
overloads. Is there a way of doing it better?
EDIT : Changed Ret
to R
. As pointed out in the comments, it isn't really the return type and the specialization was invalid.