offa 7 лет назад
Родитель
Сommit
cc09b0dfeb
3 измененных файлов: 14 добавлений и 14 удалений
  1. +5
    -5
      include/scope_exit.h
  2. +5
    -5
      include/scope_fail.h
  3. +4
    -4
      include/scope_success.h

+ 5
- 5
include/scope_exit.h Просмотреть файл

@@ -36,7 +36,7 @@ namespace sr
std::enable_if_t<(!std::is_lvalue_reference<EFP>::value)
&& std::is_nothrow_constructible<EF, EFP>::value, int> = 0
>
explicit scope_exit(EFP&& deleter) : m_exitFunction(std::move(deleter)),
explicit scope_exit(EFP&& exitFunction) : m_exitFunction(std::move(exitFunction)),
m_execute_on_destruction(true)
{
}
@@ -45,13 +45,13 @@ namespace sr
std::enable_if_t<std::is_constructible<EF, EFP>::value, int> = 0,
std::enable_if_t<std::is_lvalue_reference<EFP>::value, int> = 0
>
explicit scope_exit(EFP&& deleter) try : m_exitFunction(deleter),
explicit scope_exit(EFP&& exitFunction) try : m_exitFunction(exitFunction),
m_execute_on_destruction(true)
{
}
catch( ... )
{
deleter();
exitFunction();
throw;
}

@@ -102,9 +102,9 @@ namespace sr


template<class EF>
scope_exit<std::decay_t<EF>> make_scope_exit(EF&& deleter)
scope_exit<std::decay_t<EF>> make_scope_exit(EF&& exitFunction)
{
return scope_exit<std::decay_t<EF>>{std::forward<EF>(deleter)};
return scope_exit<std::decay_t<EF>>{std::forward<EF>(exitFunction)};
}

}

+ 5
- 5
include/scope_fail.h Просмотреть файл

@@ -37,7 +37,7 @@ namespace sr
std::enable_if_t<(!std::is_lvalue_reference<EFP>::value)
&& std::is_nothrow_constructible<EF, EFP>::value, int> = 0
>
explicit scope_fail(EFP&& deleter) : m_exitFunction(std::move(deleter)),
explicit scope_fail(EFP&& exitFunction) : m_exitFunction(std::move(exitFunction)),
m_execute_on_destruction(true),
m_uncaught_on_creation(uncaught_exceptions())
{
@@ -47,14 +47,14 @@ namespace sr
std::enable_if_t<std::is_constructible<EF, EFP>::value, int> = 0,
std::enable_if_t<std::is_lvalue_reference<EFP>::value, int> = 0
>
explicit scope_fail(EFP&& deleter) try : m_exitFunction(deleter),
explicit scope_fail(EFP&& exitFunction) try : m_exitFunction(exitFunction),
m_execute_on_destruction(true),
m_uncaught_on_creation(uncaught_exceptions())
{
}
catch( ... )
{
deleter();
exitFunction();
throw;
}

@@ -113,9 +113,9 @@ namespace sr


template<class EF>
scope_fail<std::decay_t<EF>> make_scope_fail(EF&& deleter)
scope_fail<std::decay_t<EF>> make_scope_fail(EF&& exitFunction)
{
return scope_fail<std::decay_t<EF>>{std::forward<EF>(deleter)};
return scope_fail<std::decay_t<EF>>{std::forward<EF>(exitFunction)};
}

}

+ 4
- 4
include/scope_success.h Просмотреть файл

@@ -37,7 +37,7 @@ namespace sr
std::enable_if_t<(!std::is_lvalue_reference<EFP>::value)
&& std::is_nothrow_constructible<EF, EFP>::value, int> = 0
>
explicit scope_success(EFP&& deleter) : m_exitFunction(std::move(deleter)),
explicit scope_success(EFP&& exitFunction) : m_exitFunction(std::move(exitFunction)),
m_execute_on_destruction(true),
m_uncaught_on_creation(uncaught_exceptions())
{
@@ -47,7 +47,7 @@ namespace sr
std::enable_if_t<std::is_constructible<EF, EFP>::value, int> = 0,
std::enable_if_t<std::is_lvalue_reference<EFP>::value, int> = 0
>
explicit scope_success(EFP&& deleter) try : m_exitFunction(deleter),
explicit scope_success(EFP&& exitFunction) try : m_exitFunction(exitFunction),
m_execute_on_destruction(true),
m_uncaught_on_creation(uncaught_exceptions())
{
@@ -112,9 +112,9 @@ namespace sr


template<class EF>
scope_success<std::decay_t<EF>> make_scope_success(EF&& deleter)
scope_success<std::decay_t<EF>> make_scope_success(EF&& exitFunction)
{
return scope_success<std::decay_t<EF>>{std::forward<EF>(deleter)};
return scope_success<std::decay_t<EF>>{std::forward<EF>(exitFunction)};
}

}

Загрузка…
Отмена
Сохранить