Stroustrup provides a Can_copy template. How does it work?
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; }
};
In particular, why does he need the line void(*p)(T1,T2) = constraints;
instead of an empty constructor? Are compilers allowed to produce only the functions a particular template instance uses as an optimisation?