Bladeren bron

Setting the correct noexcept value depending on the strategy.

main
offa 7 jaren geleden
bovenliggende
commit
6f3e9ac6d1
4 gewijzigde bestanden met toevoegingen van 12 en 3 verwijderingen
  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 Bestand weergeven

{ {
return true; return true;
} }

}; };


} }

+ 5
- 1
include/scope_fail.h Bestand weergeven





int m_uncaught_on_creation = uncaught_exceptions(); int m_uncaught_on_creation = uncaught_exceptions();

}; };



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

} }






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



private: private:


}; };

+ 6
- 1
include/scope_guard_base.h Bestand weergeven

namespace detail namespace detail
{ {


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


template<class EF, class Strategy> template<class EF, class Strategy>
class scope_guard_base : private Strategy class scope_guard_base : private Strategy
{ {


scope_guard_base(const scope_guard_base&) = delete; 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) ) if( (m_execute_on_destruction == true) && (this->should_execute() == true) )
{ {

+ 0
- 1
include/scope_success.h Bestand weergeven

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



int m_uncaught_on_creation = uncaught_exceptions(); int m_uncaught_on_creation = uncaught_exceptions();
}; };



Laden…
Annuleren
Opslaan