瀏覽代碼

Member renamed.

main
offa 7 年之前
父節點
當前提交
7bb2570690
共有 1 個檔案被更改,包括 6 行新增6 行删除
  1. +6
    -6
      include/scope_success.h

+ 6
- 6
include/scope_success.h 查看文件

std::enable_if_t<(!std::is_lvalue_reference<EFP>::value) std::enable_if_t<(!std::is_lvalue_reference<EFP>::value)
&& std::is_nothrow_constructible<EF, EFP>::value, int> = 0 && std::is_nothrow_constructible<EF, EFP>::value, int> = 0
> >
explicit scope_success(EFP&& deleter) : m_deleter(std::move(deleter)),
explicit scope_success(EFP&& deleter) : m_exitFunction(std::move(deleter)),
m_execute_on_destruction(true), m_execute_on_destruction(true),
m_uncaught_on_creation(uncaught_exceptions()) m_uncaught_on_creation(uncaught_exceptions())
{ {
std::enable_if_t<std::is_constructible<EF, EFP>::value, int> = 0, std::enable_if_t<std::is_constructible<EF, EFP>::value, int> = 0,
std::enable_if_t<std::is_lvalue_reference<EFP>::value, int> = 0 std::enable_if_t<std::is_lvalue_reference<EFP>::value, int> = 0
> >
explicit scope_success(EFP&& deleter) try : m_deleter(deleter),
explicit scope_success(EFP&& deleter) try : m_exitFunction(deleter),
m_execute_on_destruction(true), m_execute_on_destruction(true),
m_uncaught_on_creation(uncaught_exceptions()) m_uncaught_on_creation(uncaught_exceptions())
{ {
template<class T = EF, template<class T = EF,
std::enable_if_t<std::is_nothrow_move_constructible<T>::value, int> = 0 std::enable_if_t<std::is_nothrow_move_constructible<T>::value, int> = 0
> >
scope_success(scope_success&& other) : m_deleter(std::move(other.m_deleter)),
scope_success(scope_success&& other) : m_exitFunction(std::move(other.m_exitFunction)),
m_execute_on_destruction(other.m_execute_on_destruction), m_execute_on_destruction(other.m_execute_on_destruction),
m_uncaught_on_creation(uncaught_exceptions()) m_uncaught_on_creation(uncaught_exceptions())
{ {
template<class T = EF, template<class T = EF,
std::enable_if_t<!std::is_nothrow_move_constructible<T>::value, int> = 0 std::enable_if_t<!std::is_nothrow_move_constructible<T>::value, int> = 0
> >
scope_success(scope_success&& other) : m_deleter(other.m_deleter),
scope_success(scope_success&& other) : m_exitFunction(other.m_exitFunction),
m_execute_on_destruction(other.m_execute_on_destruction), m_execute_on_destruction(other.m_execute_on_destruction),
m_uncaught_on_creation(other.m_uncaught_on_creation) m_uncaught_on_creation(other.m_uncaught_on_creation)
{ {
{ {
if( (m_execute_on_destruction == true) && ( uncaught_exceptions() <= m_uncaught_on_creation ) ) if( (m_execute_on_destruction == true) && ( uncaught_exceptions() <= m_uncaught_on_creation ) )
{ {
m_deleter();
m_exitFunction();
} }
} }


return ( std::uncaught_exception() == true ? 1 : 0 ); return ( std::uncaught_exception() == true ? 1 : 0 );
} }


EF m_deleter;
EF m_exitFunction;
bool m_execute_on_destruction; bool m_execute_on_destruction;
int m_uncaught_on_creation; int m_uncaught_on_creation;
}; };

Loading…
取消
儲存