#include <iostream>
using namespace std;
#define FORCE_INSTANTIATE(x) (x)
template <class T>
class ExportToLua
{
public:
ExportToLua() {}
// virtual ~ExportToLua() { FORCE_INSTANTIATE(m_registered); }
private:
static int m_registered;
};
template <class T> int ExportToLua<T>::m_registered = T::exportToLua();
class Example: public ExportToLua<Example>
{
public:
Example() {}
virtual ~Example() {}
static int exportToLua();
};
int Example::exportToLua()
{
cout << "int Example::exportToLua()" << endl;
return -2;
}
//template class ExportToLua<Example>;
int main()
{
Example exam;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKI2RlZmluZSBGT1JDRV9JTlNUQU5USUFURSh4KSAoeCkKCnRlbXBsYXRlIDxjbGFzcyBUPgpjbGFzcyBFeHBvcnRUb0x1YQp7CiAgcHVibGljOgogICAgRXhwb3J0VG9MdWEoKSB7fQovLyAgICB2aXJ0dWFsIH5FeHBvcnRUb0x1YSgpIHsgRk9SQ0VfSU5TVEFOVElBVEUobV9yZWdpc3RlcmVkKTsgfQogIHByaXZhdGU6CiAgICAgIHN0YXRpYyBpbnQgbV9yZWdpc3RlcmVkOwp9Owp0ZW1wbGF0ZSA8Y2xhc3MgVD4gaW50IEV4cG9ydFRvTHVhPFQ+OjptX3JlZ2lzdGVyZWQgPSBUOjpleHBvcnRUb0x1YSgpOwoKY2xhc3MgRXhhbXBsZTogcHVibGljIEV4cG9ydFRvTHVhPEV4YW1wbGU+CnsKIHB1YmxpYzoKICAgICBFeGFtcGxlKCkge30KICAgICB2aXJ0dWFsIH5FeGFtcGxlKCkge30KICAgICBzdGF0aWMgaW50IGV4cG9ydFRvTHVhKCk7Cn07CgppbnQgRXhhbXBsZTo6ZXhwb3J0VG9MdWEoKQp7CiAgICAgY291dCA8PCAiaW50IEV4YW1wbGU6OmV4cG9ydFRvTHVhKCkiIDw8IGVuZGw7CiAgICAgcmV0dXJuIC0yOwp9CgovL3RlbXBsYXRlIGNsYXNzIEV4cG9ydFRvTHVhPEV4YW1wbGU+OwoKaW50IG1haW4oKQp7CiAgRXhhbXBsZSBleGFtOwp9