Pārlūkot izejas kodu

Copy disabled, move enabled.

main
offa pirms 7 gadiem
vecāks
revīzija
7592f6acb7
2 mainītis faili ar 8 papildinājumiem un 3 dzēšanām
  1. +2
    -2
      include/scope_guard.h
  2. +6
    -1
      include/unique_resource.h

+ 2
- 2
include/scope_guard.h Parādīt failu

@@ -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 Parādīt failu

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

Notiek ielāde…
Atcelt
Saglabāt