Browse Source

Member renamed.

main
offa 7 years ago
parent
commit
f37b0b7710
1 changed files with 6 additions and 6 deletions
  1. +6
    -6
      include/scope_fail.h

+ 6
- 6
include/scope_fail.h View File

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_fail(EFP&& deleter) : m_deleter(std::move(deleter)),
explicit scope_fail(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_fail(EFP&& deleter) try : m_deleter(deleter),
explicit scope_fail(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_fail(scope_fail&& other) : m_deleter(std::move(other.m_deleter)),
scope_fail(scope_fail&& 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_fail(scope_fail&& other) : m_deleter(other.m_deleter),
scope_fail(scope_fail&& 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…
Cancel
Save