Browse Source

Some fixes.

main
offa 7 years ago
parent
commit
454462d936
1 changed files with 9 additions and 2 deletions
  1. +9
    -2
      include/unique_resource.h

+ 9
- 2
include/unique_resource.h View File

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);

Loading…
Cancel
Save