'enforce typetrait for all subclasses
is there are a way I can check during compile time, that all subclasses of a given class satisfy a given typetrait?
For example: I want to make sure that all classes that inherit from Base are trivially copyable.
#include <type_traits>
class Base
{ };
class Foo : Base
{ };
class Bar : Foo
{ };
int main()
{
static_assert(std::is_trivially_copyable<Base>::value, "");
return 0;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
