fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class empty
  5. {};
  6.  
  7. template <class Base, int c=1>
  8. struct add_chars : Base {
  9. char dummy[c];
  10. };
  11.  
  12. template <class T>
  13. struct has_trailing_unused_space {
  14. static const bool result = sizeof (add_chars<T>) == sizeof (T);
  15. };
  16.  
  17. int main() {
  18. std::cout << "empty has trailing space: ";
  19. std::cout << has_trailing_unused_space<empty>::result;
  20. }
  21.  
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
empty has trailing space: 1