template<class T>
struct is_class_or_union
{
struct twochar { char _[2]; };
template <class U>
static char is_class_or_union_tester(void(U::*)(void));
template <class U>
static twochar is_class_or_union_tester(...);
static const bool value = sizeof(is_class_or_union_tester<T>(0)) == sizeof(char);
};
The above code is from meta_utils.hpp
from boost library.
is_class_or_union_tester
seems to be astatic
function returningchar
and taking pointer to a member function (that returns void and accepts nothing). There is no function body and it does not seem to be defined anywhere else. I do not understand how it works and above all, I do not understand the purpose of the function.- I do not understand the concept of the following code:
static const bool value = sizeof(is_class_or_union_tester<T>(0)) == sizeof(char);
What is thesizeof
operator applied to? What are they trying to find here ?