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

{ {
} }


scope_guard_t(const scope_guard_t&) = delete;

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


scope_guard_t(const scope_guard_t&) = delete;

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

+ 6
- 1
include/unique_resource.h View File

explicit unique_resource_t(Ressource&& res, Deleter&& deleter, bool shouldrun = true) noexcept : m_resource(std::move(res)), explicit unique_resource_t(Ressource&& res, Deleter&& deleter, bool shouldrun = true) noexcept : m_resource(std::move(res)),
m_deleter(std::move(deleter)), m_deleter(std::move(deleter)),
m_execute_on_destruction(shouldrun) m_execute_on_destruction(shouldrun)

{ {
} }


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


~unique_resource_t() ~unique_resource_t()
{ {
} }




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


private: private:


Ressource m_resource; Ressource m_resource;

Loading…
Cancel
Save