浏览代码

Using std::is_nothrow_swappable_v as the own implementation is not

longer needed in C++17.
main
offa 7 年前
父节点
当前提交
3b5c5c06e7
共有 1 个文件被更改,包括 3 次插入8 次删除
  1. +3
    -8
      include/unique_resource.h

+ 3
- 8
include/unique_resource.h 查看文件

constexpr auto is_nothrow_move_or_copy_constructible_from_v = is_ntmocp_constructible<T, TT>::value; constexpr auto is_nothrow_move_or_copy_constructible_from_v = is_ntmocp_constructible<T, TT>::value;




template<class T>
constexpr auto is_nothrow_swappable_v = std::is_nothrow_move_constructible_v<T>
&& std::is_nothrow_move_assignable_v<T>;




template<class T, class U = std::conditional_t<std::is_nothrow_move_constructible_v<T>, T&&, const T&>> template<class T, class U = std::conditional_t<std::is_nothrow_move_constructible_v<T>, T&&, const T&>>
constexpr U forward_if_nothrow_move_constructible(T&& value) noexcept constexpr U forward_if_nothrow_move_constructible(T&& value) noexcept
} }




void swap(unique_resource& other) noexcept(detail::is_nothrow_swappable_v<R>
&& detail::is_nothrow_swappable_v<D>
&& detail::is_nothrow_swappable_v<bool>)
void swap(unique_resource& other) noexcept(std::is_nothrow_swappable_v<R>
&& std::is_nothrow_swappable_v<D>
&& std::is_nothrow_swappable_v<bool>)
{ {
using std::swap; using std::swap;
swap(m_resource.get(), other.m_resource.get()); swap(m_resource.get(), other.m_resource.get());

正在加载...
取消
保存