fork download
  1. #include <iostream>
  2. #include <type_traits>
  3.  
  4. template <typename T>
  5. typename std::enable_if<std::is_pod<T>::value>::type* FeedFace(T& v)
  6. {
  7. static const unsigned char MAGIC[] = { 0xFE, 0xED, 0xFA, 0xCE };
  8. unsigned char *me = reinterpret_cast<unsigned char *>(&v);
  9. for( size_t ii = 0; ii < sizeof(T)/sizeof(unsigned char); ++ii )
  10. me[ii] = MAGIC[ii % sizeof(MAGIC)/sizeof(unsigned char)];
  11. }
  12.  
  13. struct Pod { char data[37]; };
  14. struct NonPod : Pod { virtual ~NonPod() { } };
  15.  
  16. int main()
  17. {
  18. Pod pod;
  19. FeedFace(pod);
  20.  
  21. NonPod nonpod;
  22. FeedFace(nonpod);
  23.  
  24. return 0;
  25. }
  26.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:22:20: error: no matching function for call to 'FeedFace(NonPod&)'
stdout
Standard output is empty