JensB
JensB

Reputation: 939

Is there a SFINAE-template to check if a class has no functions of any kind?

I want to check if a given class has only the following:

This type would be (at least visually declaration-wise) identical to a POD-type apart from the user-defined constructor and destructor. I've tried to find a term for this kind of type but I don't think it exists.

Is there a way to check this, using some SFINAE-hackery?

Upvotes: 0

Views: 149

Answers (1)

MSalters
MSalters

Reputation: 179991

No, there's no such method. Consider the following:

struct A { };
struct B { void UniqueFunctionName9814(); };

No SFINAE method can distinguish these, because you can't enumerate member function names, nor can you predict random function names. Hence B::UniqueFunctionName9814 can't be detected, and apart from B::UniqueFunctionName9814 the two classes are identical.

Upvotes: 5

Related Questions