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

Extract a helper alias for ctor SFINAE in SingletonThreadLocal

Summary: [Folly] Extract a helper alias for ctor SFINAE in `SingletonThreadLocal`.

Reviewed By: djwatson

Differential Revision: D7316150

fbshipit-source-id: 7e3c49740dab3af37afa8a7a23f4e07cd93ff217
parent 6e98ea2a
......@@ -61,6 +61,9 @@ template <
class SingletonThreadLocal {
private:
struct Wrapper {
template <typename S>
using MakeRet = is_invocable_r<S, Make>;
// keep as first field, to save 1 instr in the fast path
union {
alignas(alignof(T)) unsigned char storage[sizeof(T)];
......@@ -73,16 +76,12 @@ class SingletonThreadLocal {
}
// normal make types
template <
typename S = T,
_t<std::enable_if<is_invocable_r<S, Make>::value, int>> = 0>
template <typename S = T, _t<std::enable_if<MakeRet<S>::value, int>> = 0>
Wrapper() {
(void)new (storage) S(Make{}());
}
// default and special make types for non-move-constructible T, until C++17
template <
typename S = T,
_t<std::enable_if<!is_invocable_r<S, Make>::value, int>> = 0>
template <typename S = T, _t<std::enable_if<!MakeRet<S>::value, int>> = 0>
Wrapper() {
(void)Make{}(storage);
}
......
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