1#ifndef NEFORCE_CORE_UTILITY_SCOPE_HPP__
2#define NEFORCE_CORE_UTILITY_SCOPE_HPP__
26NEFORCE_BEGIN_NAMESPACE__
44template <
typename Func>
57 template <
typename F, enable_if_t<!is_same_v<remove_cvref_t<F>, scope_exit> && is_constructible_v<Func, F> &&
58 !is_nothrow_constructible_v<Func, F>,
73 template <
typename F, enable_if_t<!is_same_v<remove_cvref_t<F>, scope_exit> && is_constructible_v<Func, F> &&
74 is_nothrow_constructible_v<Func, F>,
89 func_pair_(
move(rhs.func_pair_)) {
102 if (func_pair_.value) {
103 func_pair_.get_base()();
112 void release() noexcept { func_pair_.value =
false; }
115#ifdef NEFORCE_STANDARD_17
116template <
typename Func>
129template <
typename Func>
142 template <
typename F, enable_if_t<!is_same_v<remove_cvref_t<F>, scope_fail> && is_constructible_v<Func, F> &&
143 !is_nothrow_constructible_v<Func, F>,
156 template <
typename F, enable_if_t<!is_same_v<remove_cvref_t<F>, scope_fail> && is_constructible_v<Func, F> &&
157 is_nothrow_constructible_v<Func, F>,
170 func_pair_(
move(rhs.func_pair_)) {
184 func_pair_.get_base()();
196#ifdef NEFORCE_STANDARD_17
197template <
typename Func>
212template <
typename Func>
223 template <
typename F, enable_if_t<!is_same_v<remove_cvref_t<F>, scope_success> && is_constructible_v<Func, F> &&
224 !is_nothrow_constructible_v<Func, F>,
237 template <
typename F, enable_if_t<!is_same_v<remove_cvref_t<F>, scope_success> && is_constructible_v<Func, F> &&
238 is_nothrow_constructible_v<Func, F>,
251 func_pair_(
move(rhs.func_pair_)) {
265 func_pair_.get_base()();
277#ifdef NEFORCE_STANDARD_17
278template <
typename Func>
284NEFORCE_END_NAMESPACE__
static NEFORCE_NODISCARD constexpr T max() noexcept
获取类型的最大值
scope_exit(scope_exit &&rhs) noexcept(is_nothrow_move_constructible_v< Func >)
移动构造函数
void release() noexcept
释放守卫
scope_exit(F &&func) noexcept
构造函数(异常安全)
~scope_exit() noexcept
析构函数
scope_exit(F &&func)
构造函数(异常不安全)
scope_fail(scope_fail &&rhs) noexcept
移动构造函数
scope_fail(F &&func) noexcept
构造函数(异常安全)
~scope_fail() noexcept
析构函数
void release() noexcept
释放守卫
scope_fail(F &&func)
构造函数(异常不安全)
void release() noexcept
释放守卫
~scope_success() noexcept(is_nothrow_invocable_v< Func >)
析构函数
scope_success(F &&func)
构造函数(异常不安全)
scope_success(F &&func) noexcept
构造函数(异常安全)
scope_success(scope_success &&rhs) noexcept(is_nothrow_move_assignable_v< Func >)
移动构造函数
NEFORCE_NODISCARD constexpr T && forward(remove_reference_t< T > &x) noexcept
完美转发左值
int NEFORCE_API uncaught_exceptions() noexcept NEFORCE_PURE_FUNCTION
未捕获的异常数量
NEFORCE_INLINE17 constexpr bool is_nothrow_invocable_v
is_nothrow_invocable的便捷变量模板
constexpr Iterator2 move(Iterator1 first, Iterator1 last, Iterator2 result) noexcept(noexcept(inner::__move_aux(first, last, result)))
移动范围元素
NEFORCE_INLINE17 constexpr bool is_nothrow_move_assignable_v
is_nothrow_move_assignable的便捷变量模板
NEFORCE_INLINE17 constexpr bool is_nothrow_move_constructible_v
is_nothrow_move_constructible的便捷变量模板