문제

By an abstract class I mean the class with at least one pure virtual method. I want the compilation to fail, if the check shows that the class is not abstract.

Is it even possible?

도움이 되었습니까?

해결책

Use std::is_abstract.

#include <type_traits>

static_assert(std::is_abstract<T>(), "T ought to be abstract.");

See it in action.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top