|
|
|
|
|
|
|
|
std::enable_if_t<is_nothrow_move_or_copy_constructible_from_v<R, RR>, int> = 0, |
|
|
std::enable_if_t<is_nothrow_move_or_copy_constructible_from_v<R, RR>, int> = 0, |
|
|
std::enable_if_t<is_nothrow_move_or_copy_constructible_from_v<D, DD>, int> = 0 |
|
|
std::enable_if_t<is_nothrow_move_or_copy_constructible_from_v<D, DD>, int> = 0 |
|
|
> |
|
|
> |
|
|
explicit unique_resource(RR&& r, DD& d) : m_resource(std::move(r)), m_deleter(std::move(d)) |
|
|
|
|
|
|
|
|
explicit unique_resource(RR&& r, DD&& d) : m_resource(std::move(r)), m_deleter(std::move(d)), m_execute_on_destruction(true) |
|
|
{ |
|
|
{ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::enable_if_t<is_nothrow_move_or_copy_constructible_from_v<R, RR>, int> = 0, |
|
|
std::enable_if_t<is_nothrow_move_or_copy_constructible_from_v<R, RR>, int> = 0, |
|
|
std::enable_if_t<is_nothrow_move_or_copy_constructible_from_v<D, DD>, int> = 0 |
|
|
std::enable_if_t<is_nothrow_move_or_copy_constructible_from_v<D, DD>, int> = 0 |
|
|
> |
|
|
> |
|
|
explicit unique_resource(RR&& r, DD& d) try : m_resource(r), m_deleter(d) |
|
|
|
|
|
|
|
|
explicit unique_resource(RR&& r, DD&& d) try : m_resource(r), m_deleter(d), m_execute_on_destruction(true) |
|
|
{ |
|
|
{ |
|
|
} |
|
|
} |
|
|
catch( ... ) |
|
|
catch( ... ) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unique_resource(const unique_resource&) = delete; |
|
|
unique_resource(const unique_resource&) = delete; |
|
|
|
|
|
|
|
|
|
|
|
~unique_resource() |
|
|
|
|
|
{ |
|
|
|
|
|
if( m_execute_on_destruction == true ) |
|
|
|
|
|
{ |
|
|
|
|
|
m_deleter(m_resource); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unique_resource& operator=(unique_resource&& other); |
|
|
unique_resource& operator=(unique_resource&& other); |