24#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
29# pragma warning(disable : 4786)
34# if defined G4LIB_BUILD_DLL
35# define DLLEXPORT __declspec(dllexport)
36# define DLLIMPORT __declspec(dllimport)
44# if defined PTL_ALLOC_EXPORT
45# define PTL_DLL DLLEXPORT
47# define PTL_DLL DLLIMPORT
55#if !defined(PTL_DEFAULT_OBJECT)
56# define PTL_DEFAULT_OBJECT(NAME) \
59 NAME(const NAME&) = default; \
60 NAME(NAME&&) = default; \
61 NAME& operator=(const NAME&) = default; \
62 NAME& operator=(NAME&&) = default;
86template <
typename Tp,
typename Tag = api::native,
typename Ptr = std::shared_ptr<Tp>,
87 typename Pair = std::pair<Ptr, Ptr>>
91 static auto _master = std::make_shared<Tp>();
92 static std::atomic<int64_t> _count(0);
93 static thread_local auto _inst =
94 Pair(_master, Ptr((_count++ == 0) ?
nullptr :
new Tp()));
100template <
typename Tp,
typename Tag = api::native,
typename Ptr = std::shared_ptr<Tp>,
101 typename Pair = std::pair<Ptr, Ptr>>
105 static thread_local auto& _pinst = GetSharedPointerPair<Tp, Tag>();
106 static thread_local auto& _inst = _pinst.second.get() ? _pinst.second : _pinst.first;
112template <
typename Tp,
typename Tag = api::native,
typename Ptr = std::shared_ptr<Tp>,
113 typename Pair = std::pair<Ptr, Ptr>>
117 static auto& _pinst = GetSharedPointerPair<Tp, Tag>();
118 static auto _inst = _pinst.first;
126 template <
typename FuncT>
139 rhs.m_functor = []() {};
146 rhs.m_functor = []() {};
G4double(* function)(G4double)
Pair & GetSharedPointerPair()
Ptr GetSharedPointerPairInstance()
Ptr GetSharedPointerPairMasterInstance()
ScopeDestructor(ScopeDestructor &&rhs) noexcept
ScopeDestructor & operator=(const ScopeDestructor &)=delete
ScopeDestructor(const ScopeDestructor &)=delete
ScopeDestructor(FuncT &&_func)
std::function< void()> m_functor
ScopeDestructor & operator=(ScopeDestructor &&rhs) noexcept