I read the Bjarne Stroustrup FAQ in C ++ and read about type parameter restrictions and how to force certain restrictions to be applied at compile time without getting ridiculous template errors, and appeared in this example:
template<class T1, class T2>
struct Can_copy {
static void constraints(T1 a, T2 b) { T2 c = a; b = a; }
Can_copy() {
void(*p)(T1, T2) = constraints;
}
};
However, I'm not quite sure how this shows up at compile time? What is the use of constraint assignment for a function pointer? Is this a kind of implicit constraint call?
Sorry if this is an obvious question, literally only read C ++ for two days, but had experience in other languages.
source
share