Преглед на файлове

Copy disabled, move enabled.

main
offa преди 7 години
родител
ревизия
7592f6acb7
променени са 2 файла, в които са добавени 8 реда и са изтрити 3 реда
  1. +2
    -2
      include/scope_guard.h
  2. +6
    -1
      include/unique_resource.h

+ 2
- 2
include/scope_guard.h Целия файл

@@ -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 Целия файл

@@ -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…
Отказ
Запис