23 #include <type_traits> 57 template <
typename FunctionType,
bool InvokeNoexcept>
65 std::is_nothrow_copy_constructible<FunctionType>{},
73 std::is_nothrow_copy_constructible<FunctionType>{},
77 std::is_nothrow_move_constructible<FunctionType>::
value)
79 std::move_if_noexcept(fn),
81 std::is_nothrow_move_constructible<FunctionType>{},
85 std::is_nothrow_move_constructible<FunctionType>::
value)
86 : function_(
std::move_if_noexcept(other.function_)) {
106 template <
typename Fn>
113 template <
typename Fn>
119 void*
operator new(std::size_t) =
delete;
122 if (InvokeNoexcept) {
137 template <
typename F,
bool INE>
183 template <
typename F>
191 #if defined(FOLLY_EXCEPTION_COUNT_USE_CXA_GET_GLOBALS) || \ 192 defined(FOLLY_EXCEPTION_COUNT_USE_GETPTD) || \ 193 defined(FOLLY_EXCEPTION_COUNT_USE_STD) 206 template <
typename FunctionType,
bool ExecuteOnException>
207 class ScopeGuardForNewException {
209 explicit ScopeGuardForNewException(
const FunctionType& fn) : guard_(fn) {}
211 explicit ScopeGuardForNewException(FunctionType&& fn)
214 ScopeGuardForNewException(ScopeGuardForNewException&& other) =
default;
216 ~ScopeGuardForNewException()
noexcept(ExecuteOnException) {
223 void*
operator new(std::size_t) =
delete;
224 void operator delete(
void*) =
delete;
233 enum class ScopeGuardOnFail {};
235 template <
typename FunctionType>
237 operator+(detail::ScopeGuardOnFail, FunctionType&& fn) {
238 return ScopeGuardForNewException<
240 true>(std::forward<FunctionType>(fn));
246 enum class ScopeGuardOnSuccess {};
248 template <
typename FunctionType>
250 operator+(ScopeGuardOnSuccess, FunctionType&& fn) {
251 return ScopeGuardForNewException<
253 false>(std::forward<FunctionType>(fn));
256 #endif // native uncaught_exception() supported 263 template <
typename FunctionType>
268 std::forward<FunctionType>(fn));
275 auto FB_ANONYMOUS_VARIABLE(SCOPE_EXIT_STATE) = \ 276 ::folly::detail::ScopeGuardOnExit() + [&]() noexcept 278 #if defined(FOLLY_EXCEPTION_COUNT_USE_CXA_GET_GLOBALS) || \ 279 defined(FOLLY_EXCEPTION_COUNT_USE_GETPTD) || \ 280 defined(FOLLY_EXCEPTION_COUNT_USE_STD) 282 auto FB_ANONYMOUS_VARIABLE(SCOPE_FAIL_STATE) = \ 283 ::folly::detail::ScopeGuardOnFail() + [&]() noexcept 285 #define SCOPE_SUCCESS \ 286 auto FB_ANONYMOUS_VARIABLE(SCOPE_SUCCESS_STATE) = \ 287 ::folly::detail::ScopeGuardOnSuccess() + [&]() 288 #endif // native uncaught_exception() supported
ScopeGuardImpl(ScopeGuardImpl &&other) noexcept(std::is_nothrow_move_constructible< FunctionType >::value)
static void warnAboutToCrash() noexcept
constexpr detail::Map< Move > move
static ScopeGuardImplBase makeEmptyScopeGuard() noexcept
ScopeGuardImpl(Fn &&fn, ScopeGuardImplBase &&failsafe)
—— Concurrent Priority Queue Implementation ——
requires E e noexcept(noexcept(s.error(std::move(e))))
bool_constant< true > true_type
ScopeGuardImpl< typename std::decay< FunctionType >::type, true > operator+(detail::ScopeGuardOnExit, FunctionType &&fn)
int uncaught_exceptions() noexcept
ScopeGuardImplBase() noexcept
static ScopeGuardImplBase makeFailsafe(std::true_type, const void *) noexcept
~ScopeGuardImpl() noexcept(InvokeNoexcept)
void execute() noexcept(InvokeNoexcept)
static const T & asConst(const T &t) noexcept
static const char *const value
static auto makeFailsafe(std::false_type, Fn *fn) noexcept-> ScopeGuardImpl< decltype(std::ref(*fn)), InvokeNoexcept >
ScopeGuardImpl(FunctionType &fn) noexcept(std::is_nothrow_copy_constructible< FunctionType >::value)
FOLLY_NODISCARD detail::ScopeGuardImplDecay< F, true > makeGuard(F &&f) noexcept(noexcept(detail::ScopeGuardImplDecay< F, true >(static_cast< F && >(f))))
T exchange(T &obj, U &&new_value)
ScopeGuardImpl(const FunctionType &fn) noexcept(std::is_nothrow_copy_constructible< FunctionType >::value)
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
bool_constant< false > false_type
ScopeGuardImpl(FunctionType &&fn) noexcept(std::is_nothrow_move_constructible< FunctionType >::value)