Skip to content

Commit

Permalink
propagate_captured_tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
zajo committed Nov 26, 2023
1 parent d8aae79 commit 916d438
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
13 changes: 1 addition & 12 deletions include/boost/leaf/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,6 @@ namespace leaf_detail
tuple_for_each<I-1,Tuple>::propagate(tup, err_id);
}

BOOST_LEAF_CONSTEXPR static void propagate_captured( Tuple & tup, int err_id ) noexcept
{
static_assert(!std::is_same<error_info, typename std::decay<decltype(std::get<I-1>(tup))>::type>::value, "Bug in LEAF: context type deduction");
BOOST_LEAF_ASSERT(err_id != 0);
auto & sl = std::get<I-1>(tup);
if( sl.has_value(err_id) )
(void) load_slot<false>(err_id, std::move(sl).value(err_id));
tuple_for_each<I-1,Tuple>::propagate_captured(tup, err_id);
}

template <class CharT, class Traits>
static void print( std::basic_ostream<CharT, Traits> & os, void const * tup, int key_to_print )
{
Expand All @@ -196,7 +186,6 @@ namespace leaf_detail
BOOST_LEAF_CONSTEXPR static void activate( Tuple & ) noexcept { }
BOOST_LEAF_CONSTEXPR static void deactivate( Tuple & ) noexcept { }
BOOST_LEAF_CONSTEXPR static void propagate( Tuple &, int ) noexcept { }
BOOST_LEAF_CONSTEXPR static void propagate_captured( Tuple &, int ) noexcept { }
template <class CharT, class Traits>
BOOST_LEAF_CONSTEXPR static void print( std::basic_ostream<CharT, Traits> &, void const *, int ) { }
};
Expand Down Expand Up @@ -289,7 +278,7 @@ class context

BOOST_LEAF_CONSTEXPR error_id propagate_captured_errors( error_id err_id ) noexcept
{
leaf_detail::tuple_for_each<std::tuple_size<Tup>::value,Tup>::propagate_captured(tup_, err_id.value());
leaf_detail::tuple_for_each<std::tuple_size<Tup>::value,Tup>::propagate(tup_, err_id.value());
return err_id;
}

Expand Down
3 changes: 2 additions & 1 deletion include/boost/leaf/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,8 @@ namespace leaf_detail
template <class E>
inline void slot<E>::propagate( int err_id ) noexcept(!BOOST_LEAF_CFG_DIAGNOSTICS)
{
if( this->key()!=err_id && err_id!=0 )
BOOST_LEAF_ASSERT(err_id);
if( this->key()!=err_id )
return;
if( impl * p = tls::read_ptr<slot<E>>() )
*p = std::move(*this);
Expand Down

0 comments on commit 916d438

Please sign in to comment.