Browse Source

Setting the correct noexcept value depending on the strategy.

main
offa 7 years ago
parent
commit
6f3e9ac6d1
4 changed files with 12 additions and 3 deletions
  1. +1
    -0
      include/scope_exit.h
  2. +5
    -1
      include/scope_fail.h
  3. +6
    -1
      include/scope_guard_base.h
  4. +0
    -1
      include/scope_success.h

+ 1
- 0
include/scope_exit.h View File

@@ -33,6 +33,7 @@ namespace sr
{
return true;
}

};

}

+ 5
- 1
include/scope_fail.h View File

@@ -42,8 +42,13 @@ namespace sr


int m_uncaught_on_creation = uncaught_exceptions();

};


template<class F>
constexpr bool is_noexcept_dtor_v<F, scope_fail_strategy> = noexcept(std::declval<F>()());

}


@@ -54,7 +59,6 @@ namespace sr

using detail::scope_guard_base<EF, detail::scope_fail_strategy>::scope_guard_base;


private:

};

+ 6
- 1
include/scope_guard_base.h View File

@@ -28,6 +28,10 @@ namespace sr
namespace detail
{

template<class F, class S>
constexpr bool is_noexcept_dtor_v = true;


template<class EF, class Strategy>
class scope_guard_base : private Strategy
{
@@ -83,7 +87,8 @@ namespace detail

scope_guard_base(const scope_guard_base&) = delete;

~scope_guard_base() noexcept(true)

~scope_guard_base() noexcept(is_noexcept_dtor_v<EF, Strategy>)
{
if( (m_execute_on_destruction == true) && (this->should_execute() == true) )
{

+ 0
- 1
include/scope_success.h View File

@@ -40,7 +40,6 @@ namespace sr
return ( std::uncaught_exception() == true ? 1 : 0 );
}


int m_uncaught_on_creation = uncaught_exceptions();
};


Loading…
Cancel
Save