Is it possible to detect a member pointer function?
I want a specialization pattern in a member pointer case. Is there a way to detect this? right now declare struct isPtrToMemberFunc, then add an extra template (class TType = void) to each class (right now only 1) and specialize the extra template to see if it's isPtrToMemberFunc. Is there a way to detect this automatically? if this is not my current method, what is the best solution?
+1
user34537
source
to share
1 answer
There is a way, but it involves repeating your specialization for every number of arguments and constant / volatile modifiers for those member functions. An easier way to do it is to use boost.functiontypes
, which does it for you:
template<typename T>
void doit(T t) {
if(boost::function_types::is_member_function_pointer<T>::value) {
std::cout << "it is";
// ...
} else {
std::cout << "it is not";
// ...
}
}
Take it from here .
+6
source to share