通过静态函数的调用实现。
#define REGISTER_SINGLETON(name, instance) \
static bool register_##name = []() { \
GetSingletonRegistry()[#name] = std::make_unique<instance>(); \
return true; \
}();
REGISTER_SINGLETON(MySingletonInstance, MySingleton);Ref:: 与 Kimi 的对话