c++ - Static assertions that a type has no data members -
c++ - Static assertions that a type has no data members -
my type has no instance info members. want ensure none accidentally added in future.
can static_assert
, type_traits
somehow? best came asserting size of type, must abstract won't work, or @ to the lowest degree not in portable fashion.
i'm happy allow static info members.
checking size of type fine idea. can create dummy class abstract, , then:
static_assert(sizeof(t) == sizeof(dummy), "oops");
that is, check size of target class same size of class known have no info members.
c++ c++11 static-assert
Comments
Post a Comment