fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. #define FORCE_INSTANTIATE(x) (x)
  5.  
  6. template <class T>
  7. class ExportToLua
  8. {
  9. public:
  10. ExportToLua() {}
  11. // virtual ~ExportToLua() { FORCE_INSTANTIATE(m_registered); }
  12. private:
  13. static int m_registered;
  14. };
  15. template <class T> int ExportToLua<T>::m_registered = T::exportToLua();
  16.  
  17. class Example: public ExportToLua<Example>
  18. {
  19. public:
  20. Example() {}
  21. virtual ~Example() {}
  22. static int exportToLua();
  23. };
  24.  
  25. int Example::exportToLua()
  26. {
  27. cout << "int Example::exportToLua()" << endl;
  28. return -2;
  29. }
  30.  
  31. //template class ExportToLua<Example>;
  32.  
  33. int main()
  34. {
  35. Example exam;
  36. }
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
Standard output is empty