1#ifndef NEFORCE_CORE_UTILITY_SCOPE_HPP__
2#define NEFORCE_CORE_UTILITY_SCOPE_HPP__
27NEFORCE_BEGIN_NAMESPACE__
45template <
typename Func>
58 template <
typename F, enable_if_t<!is_same_v<remove_cvref_t<F>, scope_exit> && is_constructible_v<Func, F> &&
59 !is_nothrow_constructible_v<Func, F>,
74 template <
typename F, enable_if_t<!is_same_v<remove_cvref_t<F>, scope_exit> && is_constructible_v<Func, F> &&
75 is_nothrow_constructible_v<Func, F>,
90 func_pair_(_NEFORCE
move(rhs.func_pair_)) {
103 if (func_pair_.value) {
104 func_pair_.get_base()();
113 void release() noexcept { func_pair_.value =
false; }
116#ifdef NEFORCE_STANDARD_17
117template <
typename Func>
130template <
typename Func>
143 template <
typename F, enable_if_t<!is_same_v<remove_cvref_t<F>, scope_fail> && is_constructible_v<Func, F> &&
144 !is_nothrow_constructible_v<Func, F>,
157 template <
typename F, enable_if_t<!is_same_v<remove_cvref_t<F>, scope_fail> && is_constructible_v<Func, F> &&
158 is_nothrow_constructible_v<Func, F>,
171 func_pair_(_NEFORCE
move(rhs.func_pair_)) {
185 func_pair_.get_base()();
197#ifdef NEFORCE_STANDARD_17
198template <
typename Func>
213template <
typename Func>
224 template <
typename F, enable_if_t<!is_same_v<remove_cvref_t<F>, scope_success> && is_constructible_v<Func, F> &&
225 !is_nothrow_constructible_v<Func, F>,
238 template <
typename F, enable_if_t<!is_same_v<remove_cvref_t<F>, scope_success> && is_constructible_v<Func, F> &&
239 is_nothrow_constructible_v<Func, F>,
252 func_pair_(_NEFORCE
move(rhs.func_pair_)) {
266 func_pair_.get_base()();
278#ifdef NEFORCE_STANDARD_17
279template <
typename Func>
285NEFORCE_END_NAMESPACE__
static 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 >)
移动构造函数
constexpr T && forward(remove_reference_t< T > &x) noexcept
完美转发左值
int uncaught_exceptions() noexcept
未捕获的异常数量
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)))
移动范围元素
constexpr bool is_nothrow_move_constructible_v
is_nothrow_move_constructible的便捷变量模板
constexpr bool is_nothrow_move_assignable_v
is_nothrow_move_assignable的便捷变量模板