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

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -