I completely see why this cannot work:
class Base {};
class A;
static_assert(std::is_base_of<Base, A>::value, "");
Because there is no information about a 'class hierarchy', but... Why cannot the following work?
class Base {};
class A : public Base {
static_assert(std::is_base_of<Base, A>::value, "");
};
(produce: an undefined class is not allowed as an argument to compiler intrinsic type trait)
The type 'A' is still not complete at line with static_assert (according to definition of this concept). However - the compiler already knows the 'class hierarchy' and could provide the answer for this.
Of course - this static_assert could be moved to destructor or whatever to fix this issue, but there are situations where it cannot be done, for example:
class Base {};
template<typename T>
struct type_of {
static_assert(std::is_base_of<Base, T>::value, "T is not derived from Base");
using type = int; //* Some normal type in real use
};
class A : public Base {
public:
type_of<A>::type foo(); // Will not compile
};
Should it not be allowed?