瀏覽代碼

Both mctor implementations of scope_guard_base refactored into one. The

handling of nothrow moveconstructible or not is now handled through
std::move_if_noexcept() (fixes #77).
main
offa 7 年之前
父節點
當前提交
6a378724e3
共有 1 個檔案被更改,包括 3 行新增18 行删除
  1. +3
    -18
      include/detail/scope_guard_base.h

+ 3
- 18
include/detail/scope_guard_base.h 查看文件

@@ -69,25 +69,10 @@ namespace detail
throw;
}

template<class T = EF,
std::enable_if_t<std::is_nothrow_move_constructible<T>::value, int> = 0
>
scope_guard_base(scope_guard_base&& other) noexcept(std::is_nothrow_move_constructible<T>::value
|| std::is_nothrow_copy_constructible<T>::value)
: Strategy(other),
m_exitFunction(std::move(other.m_exitFunction)),
m_execute_on_destruction(other.m_execute_on_destruction)
{
other.release();
}

template<class T = EF,
std::enable_if_t<!std::is_nothrow_move_constructible<T>::value, int> = 0
>
scope_guard_base(scope_guard_base&& other) noexcept(std::is_nothrow_move_constructible<T>::value
|| std::is_nothrow_copy_constructible<T>::value)
scope_guard_base(scope_guard_base&& other) noexcept(std::is_nothrow_move_constructible<EF>::value
|| std::is_nothrow_copy_constructible<EF>::value)
: Strategy(other),
m_exitFunction(other.m_exitFunction),
m_exitFunction(std::move_if_noexcept(other.m_exitFunction)),
m_execute_on_destruction(other.m_execute_on_destruction)
{
other.release();

Loading…
取消
儲存