I was looking at the implementation of the is_class template in Boost, and ran into some syntax I can’t easily decipher.
template <class U> static ::boost::type_traits::yes_type is_class_tester(void(U::*)(void));
template <class U> static ::boost::type_traits::no_type is_class_tester(...);
How do I interpret void(U::*)(void) above? I’m familiar with C, so it appears somewhat analogous to void(*)(void), but I don’t understand how U:: modifies the pointer. Can anyone help?
Thanks
*indicates a pointer, because you can access its contents by writing*p.U::*indicates a pointer to a member of classU. You can access its contents by writingu.*porpu->*p(whereuis an instance ofU).So, in your example,
void (U::*)(void)is a pointer to a member ofUthat is a function taking no arguments and returning no value.Example: