1

I've read the implementation of boost::is_class.It's obviously using SFINAE. And I've coded anotheris_class by myself. I noticed that there's a void(A::*)(void) in boost's source code. What does that mean exactly.

Here is my code:

#include<iostream>

template<typename T>
struct is_class
{
    typedef const char yes_type[1];
    typedef const char no_type[2];

    template<typename A>
    static yes_type& test(void(A::*)(void));
//What's A::*
    template<typename A>
    static no_type& test(...);

    const static bool value = sizeof(test<T>(0)) == sizeof(yes_type);
};

struct A{};
int main()
{
    std::cout<<is_class<A>::value<<std::endl;
    return 0;
}
Lkopo
  • 4,798
  • 8
  • 35
  • 60
AntiMoron
  • 1,286
  • 1
  • 11
  • 29

0 Answers0