fork download
  1. #include <iostream>
  2.  
  3. template <std::size_t N> struct Debug; // No definition
  4.  
  5. struct obj
  6. {
  7. int oldField;
  8. int newField;
  9. };
  10.  
  11.  
  12. template <> struct Debug<4> {}; // Definition for "old" sizeof;
  13.  
  14. template struct Debug<sizeof(obj)>; // instanciate Debug, issue error if definition is missing
  15.  
  16. int main() {
  17. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:14:17: error: explicit instantiation of ‘struct Debug<8ul>’ before definition of template
 template struct Debug<sizeof(obj)>; // instanciate Debug, issue error if definition is missing
                 ^~~~~~~~~~~~~~~~~~
stdout
Standard output is empty