Here is the code I was looking, Source code :
template <typename T>
struct function_traits
: public function_traits<decltype(&T::operator())>
{};
if we instantiate it with some functor X i.e function_traits<X>; , That will build the base class which is function_traits<decltype(&X::operator())> due to inheritance , but to build function_traits<decltype(&X::operator())> it’s base also has to be built, which could be function_traits<decltype(Z)>
I understand function_traits<X> != function_traits<Z>. Isn’t that recursive inheritance? 0_o.
How all things is working together?
This is illegal code. You cannot derive from an incomplete type, and at the point you try to derive from
function_traits, the type is incomplete.The only way you could get round this is if the
function_traitsyou are trying to derive from is a complete type. You can do this using specialisation:Here,
X<A>is complete when you try to derive from it, so you’re fine.