Commit f2654daf authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Let SingletonHolder impl be class member type

Summary:
[Folly] Let `SingletonHolder` impl be class member type v.s. function local type, which for arbitrary magical reasons improves rtti/debuginfo letting the debugger see the type exactly.

Could also be done by extracting `SingletonHolderImpl` as a top-level type, but that would require an additional `friend` declaration and class member type works.

Reviewed By: pixelb

Differential Revision: D13333184

fbshipit-source-id: 7de4f8c16706acb18c6869b5dcd0b9c6952efc46
parent 8d228ac4
......@@ -20,14 +20,17 @@ namespace detail {
template <typename T>
template <typename Tag, typename VaultTag>
SingletonHolder<T>& SingletonHolder<T>::singleton() {
struct SingletonHolderImpl : SingletonHolder<T> {
SingletonHolderImpl()
: SingletonHolder<T>(
{typeid(T), typeid(Tag)},
*SingletonVault::singleton<VaultTag>()) {}
};
return createGlobal<SingletonHolderImpl, void>();
struct SingletonHolder<T>::Impl : SingletonHolder<T> {
Impl()
: SingletonHolder<T>(
{typeid(T), typeid(Tag)},
*SingletonVault::singleton<VaultTag>()) {}
};
template <typename T>
template <typename Tag, typename VaultTag>
inline SingletonHolder<T>& SingletonHolder<T>::singleton() {
return detail::createGlobal<Impl<Tag, VaultTag>, void>();
}
[[noreturn]] void singletonWarnDoubleRegistrationAndAbort(
......
......@@ -322,6 +322,9 @@ struct SingletonHolder : public SingletonHolderBase {
void destroyInstance() override;
private:
template <typename Tag, typename VaultTag>
struct Impl;
SingletonHolder(TypeDescriptor type, SingletonVault& vault);
enum class SingletonHolderState {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment