Possible Duplicate:
Is there an easy way to tell if a class/struct has no data members?
Can we detect emply classes, possibly using template?
struct A {};
struct B { char c;};
std::cout << is_empty<A>::value; //should print 0
std::cout << is_empty<B>::value; //should print 1
//this is important, the alleged duplicate doesn't deal with this case!
std::cout << is_empty<int>::value; //should print 0
Only C++03 only, not C++0x!
If your compiler supports the empty base class optimization, yes.
Better: