Hi guys, referring to yesterday's post,
this woke me up this morning. Why does this actually work? As long as the function test
is concerned, this function has no body so how can it perform anything? I want to know why and how this works? I'm REALLY interested to see your answers.
template<typename T>
class IsClassT {
private:
typedef char One;
typedef struct { char a[2]; } Two;
template<typename C> static One test(int C::*); //NO BODY HERE
template<typename C> static Two test(…); //NOR HERE
public:
enum { Yes = sizeof(IsClassT<T>::template test<T>(0)) == sizeof(One) };
enum { No = !Yes };
};
Thanks in advance with help to understand this very interesting phenomenon.