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 { ...@@ -20,14 +20,17 @@ namespace detail {
template <typename T> template <typename T>
template <typename Tag, typename VaultTag> template <typename Tag, typename VaultTag>
SingletonHolder<T>& SingletonHolder<T>::singleton() { struct SingletonHolder<T>::Impl : SingletonHolder<T> {
struct SingletonHolderImpl : SingletonHolder<T> { Impl()
SingletonHolderImpl() : SingletonHolder<T>(
: SingletonHolder<T>( {typeid(T), typeid(Tag)},
{typeid(T), typeid(Tag)}, *SingletonVault::singleton<VaultTag>()) {}
*SingletonVault::singleton<VaultTag>()) {} };
};
return createGlobal<SingletonHolderImpl, void>(); template <typename T>
template <typename Tag, typename VaultTag>
inline SingletonHolder<T>& SingletonHolder<T>::singleton() {
return detail::createGlobal<Impl<Tag, VaultTag>, void>();
} }
[[noreturn]] void singletonWarnDoubleRegistrationAndAbort( [[noreturn]] void singletonWarnDoubleRegistrationAndAbort(
......
...@@ -322,6 +322,9 @@ struct SingletonHolder : public SingletonHolderBase { ...@@ -322,6 +322,9 @@ struct SingletonHolder : public SingletonHolderBase {
void destroyInstance() override; void destroyInstance() override;
private: private:
template <typename Tag, typename VaultTag>
struct Impl;
SingletonHolder(TypeDescriptor type, SingletonVault& vault); SingletonHolder(TypeDescriptor type, SingletonVault& vault);
enum class SingletonHolderState { 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