The task is to check that type T function of a certain type. We use a class of restrictions. Due to inheritance, a constructor is called. I don’t understand how it calls a static function to get (if everything is bad) an error in a line specifying an address to a function pointer. In the same way, it seems that simply assigning the address of this function to the pointer.
template<typename T> class Has_f { public: static void Constraints() { T* (T::*test)() const = &T::f; test; } Has_f() { void (*p)() = Constraints; } }; Our class:
template <typename T> class C : Has_f<T> { // ... }; Why did the author write this way? You can just call in the constructor {Constraints();} or not? The fragment is taken from the book of G. Sutter.