瀏覽代碼

Using the move_assign_if_noexcept() from the standard library instead of

the custom one.
main
offa 7 年之前
父節點
當前提交
6f308d79fb
共有 1 個檔案被更改,包括 2 行新增13 行删除
  1. +2
    -13
      include/unique_resource.h

+ 2
- 13
include/unique_resource.h 查看文件

@@ -37,17 +37,6 @@ namespace sr
constexpr auto is_nothrow_move_or_copy_constructible_from_v = is_ntmocp_constructible<T, TT>::value;


template<class T,
class U = std::conditional_t<(!std::is_nothrow_move_assignable<T>::value
&& std::is_copy_assignable<T>::value),
const T&,
T &&>>
constexpr U move_assign_if_noexcept(T& value) noexcept
{
return std::move(value);
}


template<class T, class U = std::conditional_t<std::is_nothrow_move_constructible<T>::value, T&&, const T&>>
constexpr U forward_if_nothrow_move_constructible(T&& value) noexcept
{
@@ -76,9 +65,9 @@ namespace sr
return m_value;
}

void reset(T&& newValue) noexcept(std::is_nothrow_assignable<T, decltype(move_assign_if_noexcept(newValue))>::value)
void reset(T&& newValue) noexcept(std::is_nothrow_assignable<T, decltype(std::move_assign_if_noexcept(newValue))>::value)
{
m_value = move_assign_if_noexcept(newValue);
m_value = std::move_assign_if_noexcept(newValue);
}

void reset(const T& newValue) noexcept(std::is_nothrow_assignable<T, const T&>::value)

Loading…
取消
儲存