I am learning SFINAE(Substitution failure is not) I found an example of it in a site,
template<typename T>
class is_class {
typedef char yes[1];
typedef char no [2];
template<typename C> static yes& test(int C::*); // What is C::*?
template<typename C> static no& test(...);
public:
static bool const value = sizeof(test<T>(0)) == sizeof(yes);
};
I found a new signature, int C::*
at a line 5. At first I thought it is operator*
but I suppose it is not true.
Please tell me what is it.
int C::*
is a pointer to a member of class C
whose type is int
.
Example:
struct C
{
C () : a(0), b(0) {}
int a;
int b;
};
int main()
{
int C::*member1 = &C::a;
int C::*member2 = &C::b;
C c1;
c1.*member1 = 10; // Sets the value of c1.a to 10
c1.*member2 = 20; // Sets the value of c1.b to 20
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With