Преглед изворни кода

Behaviour on Move-Construction corrected (#52).

main
offa пре 7 година
родитељ
комит
b5f28779dd
1 измењених фајлова са 14 додато и 2 уклоњено
  1. +14
    -2
      include/unique_resource.h

+ 14
- 2
include/unique_resource.h Прегледај датотеку

} }




template<class T, std::enable_if_t<std::is_nothrow_move_constructible<T>::value, int> = 0>
constexpr T&& forward_if_nothrow_move_constructible(T&& value)
{
return std::forward<T>(value);
}

template<class T, std::enable_if_t<!std::is_nothrow_move_constructible<T>::value, int> = 0>
constexpr T forward_if_nothrow_move_constructible(T&& value)
{
return value;
}



template<class R, class D> template<class R, class D>
class unique_resource class unique_resource
> >
unique_resource(unique_resource&& other) noexcept(std::is_nothrow_move_constructible<R>::value unique_resource(unique_resource&& other) noexcept(std::is_nothrow_move_constructible<R>::value
&& std::is_nothrow_move_constructible<D>::value) && std::is_nothrow_move_constructible<D>::value)
: m_resource(std::forward<R>(other.m_resource)),
m_deleter(std::forward<D>(other.m_deleter)),
: m_resource(forward_if_nothrow_move_constructible<R>(std::forward<R>(other.m_resource))),
m_deleter(forward_if_nothrow_move_constructible<D>(std::forward<D>(other.m_deleter))),
m_execute_on_destruction(std::exchange(other.m_execute_on_destruction, false)) m_execute_on_destruction(std::exchange(other.m_execute_on_destruction, false))
{ {
} }

Loading…
Откажи
Сачувај