Browse Source

Exception handling of reset(R&&) corrected (fixes #55, fixes #56).

main
offa 7 years ago
parent
commit
43cad551f2
1 changed files with 3 additions and 1 deletions
  1. +3
    -1
      include/unique_resource.h

+ 3
- 1
include/unique_resource.h View File



#pragma once #pragma once


#include "scope_exit.h"
#include <utility> #include <utility>
#include <type_traits> #include <type_traits>


template<class RR> template<class RR>
void reset(RR&& r) void reset(RR&& r)
{ {
auto se = make_scope_exit([this, &r] { get_deleter()(r); });
reset(); reset();

m_resource = move_assign_if_noexcept(r); m_resource = move_assign_if_noexcept(r);
m_execute_on_destruction = true; m_execute_on_destruction = true;
se.release();
} }


void release() void release()

Loading…
Cancel
Save