Hallo,
is there some easy way in C++ to tell (in compile-time) if a class/struct has no data members?
E.g. struct T{};
struct T{};
My first thought
Stepping on Konrad's answer, this handles classes with or without virtual functions.
template struct is_empty { struct empty_ { virtual ~empty_(); }; struct helper_ : T { virtual ~helper_(); }; static bool const EMPTY = sizeof(helper_) == sizeof(empty_); };