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

Tweak createGlobal

Summary: [Folly] Tweak createGlobal: use a local struct and padd a general callable.

Reviewed By: andrewjcg

Differential Revision: D13113756

fbshipit-source-id: a40f43280e5f83f08963c7ecedcb82fab65c95b4
parent 689ef909
...@@ -71,18 +71,14 @@ FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN T* createGlobal(F&& creator) { ...@@ -71,18 +71,14 @@ FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN T* createGlobal(F&& creator) {
return StaticSingletonManager::create<T, Tag>(static_cast<F&&>(creator)); return StaticSingletonManager::create<T, Tag>(static_cast<F&&>(creator));
} }
// TODO(T36779215): A bug in the gcc-5-glibc-2.23 llvm-fb/clang doesn't like
// passing this as a lambda (e.g. P60328775).
namespace {
template <typename T>
T* singleton_global_cons() {
return new T();
}
} // namespace
template <typename T, typename Tag> template <typename T, typename Tag>
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN T* createGlobal() { FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN T* createGlobal() {
return createGlobal<T, Tag>(&singleton_global_cons<T>); struct construct {
T* operator()() const {
return new T();
}
};
return createGlobal<T, Tag>(construct{});
} }
} // namespace detail } // namespace detail
......
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