Browse Source

Copy disabled, move enabled.

main
offa 7 years ago
parent
commit
7592f6acb7
2 changed files with 8 additions and 3 deletions
  1. +2
    -2
      include/scope_guard.h
  2. +6
    -1
      include/unique_resource.h

+ 2
- 2
include/scope_guard.h View File

@@ -35,14 +35,14 @@ namespace sr
{
}

scope_guard_t(const scope_guard_t&) = delete;

scope_guard_t(scope_guard_t&& other) noexcept : m_deleter(std::move(other.m_deleter)),
m_execute_on_destruction(other.m_execute_on_destruction)
{
other.release();
}

scope_guard_t(const scope_guard_t&) = delete;

~scope_guard_t()
{
if( m_execute_on_destruction == true )

+ 6
- 1
include/unique_resource.h View File

@@ -32,10 +32,11 @@ namespace sr
explicit unique_resource_t(Ressource&& res, Deleter&& deleter, bool shouldrun = true) noexcept : m_resource(std::move(res)),
m_deleter(std::move(deleter)),
m_execute_on_destruction(shouldrun)

{
}

unique_resource_t(const unique_resource_t&) = delete;
unique_resource_t(unique_resource_t&&) = default;

~unique_resource_t()
{
@@ -53,6 +54,10 @@ namespace sr
}


unique_resource_t& operator=(unique_resource_t&&) = default;
unique_resource_t& operator=(const unique_resource_t&) = delete;


private:

Ressource m_resource;

Loading…
Cancel
Save