I have a class which has a variadic member function:
class class_name {
template<ArgTypes.. args>
some_return_type memberMethod(ArgTypes... args) {
//stuff...
}
}
I need to force instantiation of this method inside the class definition block. I loose the method name outside of the class definition block because the class is generated by a bunch of macros.
I try to force the instantiation by copying a pointer to a specialised member function (pseudo code):
template<typename Self, typename RetType, typename... ArgTypes>
struct force_instantation_imlp<Self, RetType, type_placeholder, type_placeholder<ArgTypes...>> {
force_instantation_imlp() {
using instate = RetType (Self::*)(ArgTypes...);
instate force = &Self::memberMethod<ArgTypes...>;
}
};
class class_name {
template<ArgTypes.. args>
some_return_type memberMethod(ArgTypes... args) {
//stuff...
}
force_instantation_imlp<class_name, some_return_type, rest_of_types_deduced_from_context> force_virtual_instantation;
}
type_placeholder
is just a helper template to "freeze" parameter pack.
This unfortunately gives me a compile error
error: expected primary-expression before ‘...’ token instate force = &Self::memberMethod<ArgTypes...>;
I guess that this error results from teh fact that the member function is a variadic template.
Is there any way to force variadic template member function instantiation inside the class definition block?