mirror of
https://github.com/boostorg/leaf.git
synced 2026-01-19 04:22:08 +00:00
context_activator modified to avoid virtual function calls on context activation/deactivation
This commit is contained in:
@@ -124,7 +124,7 @@ auto async_demo_rpc(AsyncStream &stream, ErrorContext &error_context, Completion
|
||||
void operator()(error_code ec, std::size_t /*bytes_transferred*/ = 0) {
|
||||
leaf::result<bool> result_continue_execution;
|
||||
{
|
||||
leaf::context_activator active_context{m_error_context, leaf::on_deactivation::do_not_propagate};
|
||||
leaf::context_activator<> active_context{m_error_context, leaf::on_deactivation::do_not_propagate};
|
||||
auto load = leaf::preload(e_last_operation{m_data.response ? "async_demo_rpc::continuation-write"
|
||||
: "async_demo_rpc::continuation-read"});
|
||||
if (ec == http::error::end_of_stream) {
|
||||
@@ -540,9 +540,9 @@ int main(int argc, char **argv) {
|
||||
// Note: In case we wanted to add some additional information to the error associated with the result
|
||||
// we would need to activate the error-context
|
||||
// In this example this is not the case, so the next line is commented out.
|
||||
// leaf::context_activator active_context(error_context, leaf::on_deactivation::do_not_propagate);
|
||||
// leaf::context_activator<> active_context(error_context, leaf::on_deactivation::do_not_propagate);
|
||||
|
||||
leaf::context_activator active_context(error_context, leaf::on_deactivation::do_not_propagate);
|
||||
leaf::context_activator<> active_context(error_context, leaf::on_deactivation::do_not_propagate);
|
||||
if (result) {
|
||||
std::cout << "Server: Client work completed successfully" << std::endl;
|
||||
rv = 0;
|
||||
|
||||
@@ -1501,18 +1501,19 @@ namespace boost { namespace leaf {
|
||||
propagate_if_uncaught_exception
|
||||
};
|
||||
|
||||
template <class Ctx = polymorphic_context>
|
||||
class context_activator
|
||||
{
|
||||
context_activator( context_activator const & ) = delete;
|
||||
context_activator & operator=( context_activator const & ) = delete;
|
||||
|
||||
polymorphic_context & ctx_;
|
||||
Ctx & ctx_;
|
||||
on_deactivation on_deactivate_;
|
||||
bool const ctx_was_active_;
|
||||
|
||||
public:
|
||||
|
||||
context_activator( polymorphic_context & ctx, on_deactivation on_deactivate ) noexcept:
|
||||
context_activator( Ctx & ctx, on_deactivation on_deactivate ) noexcept:
|
||||
ctx_(ctx),
|
||||
on_deactivate_(on_deactivate),
|
||||
ctx_was_active_(ctx_.is_active())
|
||||
@@ -1685,7 +1686,7 @@ namespace boost { namespace leaf {
|
||||
|
||||
[[noreturn]] void unload_and_rethrow_original_exception() const
|
||||
{
|
||||
context_activator active_context(*ctx_, on_deactivation::propagate);
|
||||
context_activator<> active_context(*ctx_, on_deactivation::propagate);
|
||||
std::rethrow_exception(ex_);
|
||||
}
|
||||
|
||||
@@ -1698,7 +1699,7 @@ namespace boost { namespace leaf {
|
||||
template <class R, class F, class... A>
|
||||
inline decltype(std::declval<F>()(std::forward<A>(std::declval<A>())...)) capture_impl(is_result_tag<R, false>, context_ptr const & ctx, F && f, A... a)
|
||||
{
|
||||
context_activator active_context(*ctx, on_deactivation::do_not_propagate);
|
||||
context_activator<> active_context(*ctx, on_deactivation::do_not_propagate);
|
||||
try
|
||||
{
|
||||
return std::forward<F>(f)(std::forward<A>(a)...);
|
||||
@@ -1716,7 +1717,7 @@ namespace boost { namespace leaf {
|
||||
template <class R, class F, class... A>
|
||||
inline decltype(std::declval<F>()(std::forward<A>(std::declval<A>())...)) capture_impl(is_result_tag<R, true>, context_ptr const & ctx, F && f, A... a)
|
||||
{
|
||||
context_activator active_context(*ctx, on_deactivation::do_not_propagate);
|
||||
context_activator<> active_context(*ctx, on_deactivation::do_not_propagate);
|
||||
try
|
||||
{
|
||||
if( auto r = std::forward<F>(f)(std::forward<A>(a)...) )
|
||||
@@ -1745,14 +1746,14 @@ namespace boost { namespace leaf {
|
||||
template <class R, class F, class... A>
|
||||
inline decltype(std::declval<F>()(std::forward<A>(std::declval<A>())...)) capture_impl(is_result_tag<R, false>, context_ptr const & ctx, F && f, A... a)
|
||||
{
|
||||
context_activator active_context(*ctx, on_deactivation::do_not_propagate);
|
||||
context_activator<> active_context(*ctx, on_deactivation::do_not_propagate);
|
||||
return std::forward<F>(f)(std::forward<A>(a)...);
|
||||
}
|
||||
|
||||
template <class R, class F, class... A>
|
||||
inline decltype(std::declval<F>()(std::forward<A>(std::declval<A>())...)) capture_impl(is_result_tag<R, true>, context_ptr const & ctx, F && f, A... a)
|
||||
{
|
||||
context_activator active_context(*ctx, on_deactivation::do_not_propagate);
|
||||
context_activator<> active_context(*ctx, on_deactivation::do_not_propagate);
|
||||
if( auto r = std::forward<F>(f)(std::forward<A>(a)...) )
|
||||
return r;
|
||||
else
|
||||
@@ -2216,11 +2217,11 @@ namespace boost { namespace leaf {
|
||||
template <class TryBlock, class RemoteH>
|
||||
typename std::decay<decltype(std::declval<TryBlock>()().value())>::type remote_try_handle_all_( TryBlock &&, RemoteH && ) const;
|
||||
|
||||
template <class TryBlock, class... H>
|
||||
typename std::decay<decltype(std::declval<TryBlock>()())>::type try_handle_some_( context_activator &, TryBlock &&, H && ... ) const;
|
||||
template <class TryBlock, class... H, class Ctx>
|
||||
typename std::decay<decltype(std::declval<TryBlock>()())>::type try_handle_some_( context_activator<Ctx> &, TryBlock &&, H && ... ) const;
|
||||
|
||||
template <class TryBlock, class RemoteH>
|
||||
typename std::decay<decltype(std::declval<TryBlock>()())>::type remote_try_handle_some_( context_activator &, TryBlock &&, RemoteH && ) const;
|
||||
template <class TryBlock, class RemoteH, class Ctx>
|
||||
typename std::decay<decltype(std::declval<TryBlock>()())>::type remote_try_handle_some_( context_activator<Ctx> &, TryBlock &&, RemoteH && ) const;
|
||||
|
||||
public:
|
||||
|
||||
@@ -3210,8 +3211,8 @@ namespace boost { namespace leaf {
|
||||
}
|
||||
|
||||
template <class... E>
|
||||
template <class TryBlock, class... H>
|
||||
inline typename std::decay<decltype(std::declval<TryBlock>()())>::type context_base<E...>::try_handle_some_( context_activator & active_context, TryBlock && try_block, H && ... h ) const
|
||||
template <class TryBlock, class... H, class Ctx>
|
||||
inline typename std::decay<decltype(std::declval<TryBlock>()())>::type context_base<E...>::try_handle_some_( context_activator<Ctx> & active_context, TryBlock && try_block, H && ... h ) const
|
||||
{
|
||||
using namespace leaf_detail;
|
||||
static_assert(is_result_type<decltype(std::declval<TryBlock>()())>::value, "The return type of the try_block passed to a try_handle_some function must be registered with leaf::is_result_type");
|
||||
@@ -3228,8 +3229,8 @@ namespace boost { namespace leaf {
|
||||
}
|
||||
|
||||
template <class... E>
|
||||
template <class TryBlock, class RemoteH>
|
||||
inline typename std::decay<decltype(std::declval<TryBlock>()())>::type context_base<E...>::remote_try_handle_some_( context_activator & active_context, TryBlock && try_block, RemoteH && h ) const
|
||||
template <class TryBlock, class RemoteH, class Ctx>
|
||||
inline typename std::decay<decltype(std::declval<TryBlock>()())>::type context_base<E...>::remote_try_handle_some_( context_activator<Ctx> & active_context, TryBlock && try_block, RemoteH && h ) const
|
||||
{
|
||||
using namespace leaf_detail;
|
||||
static_assert(is_result_type<decltype(std::declval<TryBlock>()())>::value, "The return type of the try_block passed to a remote_try_handle_some function must be registered with leaf::is_result_type");
|
||||
@@ -3335,7 +3336,7 @@ namespace boost { namespace leaf {
|
||||
template <class TryBlock, class... H>
|
||||
inline typename std::decay<decltype(std::declval<TryBlock>()().value())>::type nocatch_context<E...>::try_handle_all( TryBlock && try_block, H && ... h )
|
||||
{
|
||||
context_activator active_context(*this, on_deactivation::do_not_propagate);
|
||||
context_activator<nocatch_context<E...>> active_context(*this, on_deactivation::do_not_propagate);
|
||||
return this->try_handle_all_( std::forward<TryBlock>(try_block), std::forward<H>(h)... );
|
||||
}
|
||||
|
||||
@@ -3343,7 +3344,7 @@ namespace boost { namespace leaf {
|
||||
template <class TryBlock, class RemoteH>
|
||||
inline typename std::decay<decltype(std::declval<TryBlock>()().value())>::type nocatch_context<E...>::remote_try_handle_all( TryBlock && try_block, RemoteH && h )
|
||||
{
|
||||
context_activator active_context(*this, on_deactivation::do_not_propagate);
|
||||
context_activator<nocatch_context<E...>> active_context(*this, on_deactivation::do_not_propagate);
|
||||
return this->remote_try_handle_all_( std::forward<TryBlock>(try_block), std::forward<RemoteH>(h) );
|
||||
}
|
||||
|
||||
@@ -3351,7 +3352,7 @@ namespace boost { namespace leaf {
|
||||
template <class TryBlock, class... H>
|
||||
inline typename std::decay<decltype(std::declval<TryBlock>()())>::type nocatch_context<E...>::try_handle_some( TryBlock && try_block, H && ... h )
|
||||
{
|
||||
context_activator active_context(*this, on_deactivation::propagate_if_uncaught_exception);
|
||||
context_activator<nocatch_context<E...>> active_context(*this, on_deactivation::propagate_if_uncaught_exception);
|
||||
return this->try_handle_some_( active_context, std::forward<TryBlock>(try_block), std::forward<H>(h)... );
|
||||
}
|
||||
|
||||
@@ -3359,7 +3360,7 @@ namespace boost { namespace leaf {
|
||||
template <class TryBlock, class RemoteH>
|
||||
inline typename std::decay<decltype(std::declval<TryBlock>()())>::type nocatch_context<E...>::remote_try_handle_some( TryBlock && try_block, RemoteH && h )
|
||||
{
|
||||
context_activator active_context(*this, on_deactivation::propagate_if_uncaught_exception);
|
||||
context_activator<nocatch_context<E...>> active_context(*this, on_deactivation::propagate_if_uncaught_exception);
|
||||
return this->remote_try_handle_some_( active_context, std::forward<TryBlock>(try_block), std::forward<RemoteH>(h) );
|
||||
}
|
||||
}
|
||||
@@ -3617,7 +3618,7 @@ namespace boost { namespace leaf {
|
||||
{
|
||||
using namespace leaf_detail;
|
||||
context_type_from_handlers<H...> ctx;
|
||||
context_activator active_context(ctx, on_deactivation::propagate_if_uncaught_exception);
|
||||
context_activator<decltype(ctx)> active_context(ctx, on_deactivation::propagate_if_uncaught_exception);
|
||||
return ctx.try_catch_(
|
||||
[&]
|
||||
{
|
||||
@@ -3631,7 +3632,7 @@ namespace boost { namespace leaf {
|
||||
{
|
||||
using namespace leaf_detail;
|
||||
context_type_from_remote_handler<RemoteH> ctx;
|
||||
context_activator active_context(ctx, on_deactivation::propagate_if_uncaught_exception);
|
||||
context_activator<decltype(ctx)> active_context(ctx, on_deactivation::propagate_if_uncaught_exception);
|
||||
return ctx.remote_try_catch_(
|
||||
[&]
|
||||
{
|
||||
@@ -3686,7 +3687,7 @@ namespace boost { namespace leaf {
|
||||
{
|
||||
using namespace leaf_detail;
|
||||
static_assert(is_result_type<decltype(std::declval<TryBlock>()())>::value, "The return type of the try_block passed to a try_handle_all function must be registered with leaf::is_result_type");
|
||||
context_activator active_context(*this, on_deactivation::propagate_if_uncaught_exception);
|
||||
context_activator<catch_context<E...>> active_context(*this, on_deactivation::propagate_if_uncaught_exception);
|
||||
if( auto r = this->try_catch_(
|
||||
[&]
|
||||
{
|
||||
@@ -3704,7 +3705,7 @@ namespace boost { namespace leaf {
|
||||
{
|
||||
using namespace leaf_detail;
|
||||
static_assert(is_result_type<decltype(std::declval<TryBlock>()())>::value, "The return type of the try_block passed to a try_handle_all function must be registered with leaf::is_result_type");
|
||||
context_activator active_context(*this, on_deactivation::propagate_if_uncaught_exception);
|
||||
context_activator<catch_context<E...>> active_context(*this, on_deactivation::propagate_if_uncaught_exception);
|
||||
if( auto r = this->remote_try_catch_(
|
||||
[&]
|
||||
{
|
||||
@@ -3722,7 +3723,7 @@ namespace boost { namespace leaf {
|
||||
{
|
||||
using namespace leaf_detail;
|
||||
static_assert(is_result_type<decltype(std::declval<TryBlock>()())>::value, "The return type of the try_block passed to a try_handle_some function must be registered with leaf::is_result_type");
|
||||
context_activator active_context(*this, on_deactivation::propagate_if_uncaught_exception);
|
||||
context_activator<catch_context<E...>> active_context(*this, on_deactivation::propagate_if_uncaught_exception);
|
||||
if( auto r = this->try_catch_(
|
||||
[&]
|
||||
{
|
||||
@@ -3743,7 +3744,7 @@ namespace boost { namespace leaf {
|
||||
template <class TryBlock, class RemoteH>
|
||||
inline typename std::decay<decltype(std::declval<TryBlock>()())>::type catch_context<E...>::remote_try_handle_some( TryBlock && try_block, RemoteH && h )
|
||||
{
|
||||
context_activator active_context(*this, on_deactivation::propagate_if_uncaught_exception);
|
||||
context_activator<catch_context<E...>> active_context(*this, on_deactivation::propagate_if_uncaught_exception);
|
||||
if( auto r = this->remote_try_catch_(
|
||||
[&]
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace boost { namespace leaf {
|
||||
|
||||
[[noreturn]] void unload_and_rethrow_original_exception() const
|
||||
{
|
||||
context_activator active_context(*ctx_, on_deactivation::propagate);
|
||||
context_activator<> active_context(*ctx_, on_deactivation::propagate);
|
||||
std::rethrow_exception(ex_);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace boost { namespace leaf {
|
||||
template <class R, class F, class... A>
|
||||
inline decltype(std::declval<F>()(std::forward<A>(std::declval<A>())...)) capture_impl(is_result_tag<R, false>, context_ptr const & ctx, F && f, A... a)
|
||||
{
|
||||
context_activator active_context(*ctx, on_deactivation::do_not_propagate);
|
||||
context_activator<> active_context(*ctx, on_deactivation::do_not_propagate);
|
||||
try
|
||||
{
|
||||
return std::forward<F>(f)(std::forward<A>(a)...);
|
||||
@@ -64,7 +64,7 @@ namespace boost { namespace leaf {
|
||||
template <class R, class F, class... A>
|
||||
inline decltype(std::declval<F>()(std::forward<A>(std::declval<A>())...)) capture_impl(is_result_tag<R, true>, context_ptr const & ctx, F && f, A... a)
|
||||
{
|
||||
context_activator active_context(*ctx, on_deactivation::do_not_propagate);
|
||||
context_activator<> active_context(*ctx, on_deactivation::do_not_propagate);
|
||||
try
|
||||
{
|
||||
if( auto r = std::forward<F>(f)(std::forward<A>(a)...) )
|
||||
@@ -93,14 +93,14 @@ namespace boost { namespace leaf {
|
||||
template <class R, class F, class... A>
|
||||
inline decltype(std::declval<F>()(std::forward<A>(std::declval<A>())...)) capture_impl(is_result_tag<R, false>, context_ptr const & ctx, F && f, A... a)
|
||||
{
|
||||
context_activator active_context(*ctx, on_deactivation::do_not_propagate);
|
||||
context_activator<> active_context(*ctx, on_deactivation::do_not_propagate);
|
||||
return std::forward<F>(f)(std::forward<A>(a)...);
|
||||
}
|
||||
|
||||
template <class R, class F, class... A>
|
||||
inline decltype(std::declval<F>()(std::forward<A>(std::declval<A>())...)) capture_impl(is_result_tag<R, true>, context_ptr const & ctx, F && f, A... a)
|
||||
{
|
||||
context_activator active_context(*ctx, on_deactivation::do_not_propagate);
|
||||
context_activator<> active_context(*ctx, on_deactivation::do_not_propagate);
|
||||
if( auto r = std::forward<F>(f)(std::forward<A>(a)...) )
|
||||
return r;
|
||||
else
|
||||
|
||||
@@ -288,11 +288,11 @@ namespace boost { namespace leaf {
|
||||
template <class TryBlock, class RemoteH>
|
||||
typename std::decay<decltype(std::declval<TryBlock>()().value())>::type remote_try_handle_all_( TryBlock &&, RemoteH && ) const;
|
||||
|
||||
template <class TryBlock, class... H>
|
||||
typename std::decay<decltype(std::declval<TryBlock>()())>::type try_handle_some_( context_activator &, TryBlock &&, H && ... ) const;
|
||||
template <class TryBlock, class... H, class Ctx>
|
||||
typename std::decay<decltype(std::declval<TryBlock>()())>::type try_handle_some_( context_activator<Ctx> &, TryBlock &&, H && ... ) const;
|
||||
|
||||
template <class TryBlock, class RemoteH>
|
||||
typename std::decay<decltype(std::declval<TryBlock>()())>::type remote_try_handle_some_( context_activator &, TryBlock &&, RemoteH && ) const;
|
||||
template <class TryBlock, class RemoteH, class Ctx>
|
||||
typename std::decay<decltype(std::declval<TryBlock>()())>::type remote_try_handle_some_( context_activator<Ctx> &, TryBlock &&, RemoteH && ) const;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
@@ -779,8 +779,8 @@ namespace boost { namespace leaf {
|
||||
}
|
||||
|
||||
template <class... E>
|
||||
template <class TryBlock, class... H>
|
||||
inline typename std::decay<decltype(std::declval<TryBlock>()())>::type context_base<E...>::try_handle_some_( context_activator & active_context, TryBlock && try_block, H && ... h ) const
|
||||
template <class TryBlock, class... H, class Ctx>
|
||||
inline typename std::decay<decltype(std::declval<TryBlock>()())>::type context_base<E...>::try_handle_some_( context_activator<Ctx> & active_context, TryBlock && try_block, H && ... h ) const
|
||||
{
|
||||
using namespace leaf_detail;
|
||||
static_assert(is_result_type<decltype(std::declval<TryBlock>()())>::value, "The return type of the try_block passed to a try_handle_some function must be registered with leaf::is_result_type");
|
||||
@@ -797,8 +797,8 @@ namespace boost { namespace leaf {
|
||||
}
|
||||
|
||||
template <class... E>
|
||||
template <class TryBlock, class RemoteH>
|
||||
inline typename std::decay<decltype(std::declval<TryBlock>()())>::type context_base<E...>::remote_try_handle_some_( context_activator & active_context, TryBlock && try_block, RemoteH && h ) const
|
||||
template <class TryBlock, class RemoteH, class Ctx>
|
||||
inline typename std::decay<decltype(std::declval<TryBlock>()())>::type context_base<E...>::remote_try_handle_some_( context_activator<Ctx> & active_context, TryBlock && try_block, RemoteH && h ) const
|
||||
{
|
||||
using namespace leaf_detail;
|
||||
static_assert(is_result_type<decltype(std::declval<TryBlock>()())>::value, "The return type of the try_block passed to a remote_try_handle_some function must be registered with leaf::is_result_type");
|
||||
|
||||
@@ -757,18 +757,19 @@ namespace boost { namespace leaf {
|
||||
propagate_if_uncaught_exception
|
||||
};
|
||||
|
||||
template <class Ctx = polymorphic_context>
|
||||
class context_activator
|
||||
{
|
||||
context_activator( context_activator const & ) = delete;
|
||||
context_activator & operator=( context_activator const & ) = delete;
|
||||
|
||||
polymorphic_context & ctx_;
|
||||
Ctx & ctx_;
|
||||
on_deactivation on_deactivate_;
|
||||
bool const ctx_was_active_;
|
||||
|
||||
public:
|
||||
|
||||
context_activator( polymorphic_context & ctx, on_deactivation on_deactivate ) noexcept:
|
||||
context_activator( Ctx & ctx, on_deactivation on_deactivate ) noexcept:
|
||||
ctx_(ctx),
|
||||
on_deactivate_(on_deactivate),
|
||||
ctx_was_active_(ctx_.is_active())
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace boost { namespace leaf {
|
||||
template <class TryBlock, class... H>
|
||||
inline typename std::decay<decltype(std::declval<TryBlock>()().value())>::type nocatch_context<E...>::try_handle_all( TryBlock && try_block, H && ... h )
|
||||
{
|
||||
context_activator active_context(*this, on_deactivation::do_not_propagate);
|
||||
context_activator<nocatch_context<E...>> active_context(*this, on_deactivation::do_not_propagate);
|
||||
return this->try_handle_all_( std::forward<TryBlock>(try_block), std::forward<H>(h)... );
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace boost { namespace leaf {
|
||||
template <class TryBlock, class RemoteH>
|
||||
inline typename std::decay<decltype(std::declval<TryBlock>()().value())>::type nocatch_context<E...>::remote_try_handle_all( TryBlock && try_block, RemoteH && h )
|
||||
{
|
||||
context_activator active_context(*this, on_deactivation::do_not_propagate);
|
||||
context_activator<nocatch_context<E...>> active_context(*this, on_deactivation::do_not_propagate);
|
||||
return this->remote_try_handle_all_( std::forward<TryBlock>(try_block), std::forward<RemoteH>(h) );
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace boost { namespace leaf {
|
||||
template <class TryBlock, class... H>
|
||||
inline typename std::decay<decltype(std::declval<TryBlock>()())>::type nocatch_context<E...>::try_handle_some( TryBlock && try_block, H && ... h )
|
||||
{
|
||||
context_activator active_context(*this, on_deactivation::propagate_if_uncaught_exception);
|
||||
context_activator<nocatch_context<E...>> active_context(*this, on_deactivation::propagate_if_uncaught_exception);
|
||||
return this->try_handle_some_( active_context, std::forward<TryBlock>(try_block), std::forward<H>(h)... );
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace boost { namespace leaf {
|
||||
template <class TryBlock, class RemoteH>
|
||||
inline typename std::decay<decltype(std::declval<TryBlock>()())>::type nocatch_context<E...>::remote_try_handle_some( TryBlock && try_block, RemoteH && h )
|
||||
{
|
||||
context_activator active_context(*this, on_deactivation::propagate_if_uncaught_exception);
|
||||
context_activator<nocatch_context<E...>> active_context(*this, on_deactivation::propagate_if_uncaught_exception);
|
||||
return this->remote_try_handle_some_( active_context, std::forward<TryBlock>(try_block), std::forward<RemoteH>(h) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace boost { namespace leaf {
|
||||
{
|
||||
using namespace leaf_detail;
|
||||
context_type_from_handlers<H...> ctx;
|
||||
context_activator active_context(ctx, on_deactivation::propagate_if_uncaught_exception);
|
||||
context_activator<decltype(ctx)> active_context(ctx, on_deactivation::propagate_if_uncaught_exception);
|
||||
return ctx.try_catch_(
|
||||
[&]
|
||||
{
|
||||
@@ -138,7 +138,7 @@ namespace boost { namespace leaf {
|
||||
{
|
||||
using namespace leaf_detail;
|
||||
context_type_from_remote_handler<RemoteH> ctx;
|
||||
context_activator active_context(ctx, on_deactivation::propagate_if_uncaught_exception);
|
||||
context_activator<decltype(ctx)> active_context(ctx, on_deactivation::propagate_if_uncaught_exception);
|
||||
return ctx.remote_try_catch_(
|
||||
[&]
|
||||
{
|
||||
@@ -193,7 +193,7 @@ namespace boost { namespace leaf {
|
||||
{
|
||||
using namespace leaf_detail;
|
||||
static_assert(is_result_type<decltype(std::declval<TryBlock>()())>::value, "The return type of the try_block passed to a try_handle_all function must be registered with leaf::is_result_type");
|
||||
context_activator active_context(*this, on_deactivation::propagate_if_uncaught_exception);
|
||||
context_activator<catch_context<E...>> active_context(*this, on_deactivation::propagate_if_uncaught_exception);
|
||||
if( auto r = this->try_catch_(
|
||||
[&]
|
||||
{
|
||||
@@ -211,7 +211,7 @@ namespace boost { namespace leaf {
|
||||
{
|
||||
using namespace leaf_detail;
|
||||
static_assert(is_result_type<decltype(std::declval<TryBlock>()())>::value, "The return type of the try_block passed to a try_handle_all function must be registered with leaf::is_result_type");
|
||||
context_activator active_context(*this, on_deactivation::propagate_if_uncaught_exception);
|
||||
context_activator<catch_context<E...>> active_context(*this, on_deactivation::propagate_if_uncaught_exception);
|
||||
if( auto r = this->remote_try_catch_(
|
||||
[&]
|
||||
{
|
||||
@@ -229,7 +229,7 @@ namespace boost { namespace leaf {
|
||||
{
|
||||
using namespace leaf_detail;
|
||||
static_assert(is_result_type<decltype(std::declval<TryBlock>()())>::value, "The return type of the try_block passed to a try_handle_some function must be registered with leaf::is_result_type");
|
||||
context_activator active_context(*this, on_deactivation::propagate_if_uncaught_exception);
|
||||
context_activator<catch_context<E...>> active_context(*this, on_deactivation::propagate_if_uncaught_exception);
|
||||
if( auto r = this->try_catch_(
|
||||
[&]
|
||||
{
|
||||
@@ -250,7 +250,7 @@ namespace boost { namespace leaf {
|
||||
template <class TryBlock, class RemoteH>
|
||||
inline typename std::decay<decltype(std::declval<TryBlock>()())>::type catch_context<E...>::remote_try_handle_some( TryBlock && try_block, RemoteH && h )
|
||||
{
|
||||
context_activator active_context(*this, on_deactivation::propagate_if_uncaught_exception);
|
||||
context_activator<catch_context<E...>> active_context(*this, on_deactivation::propagate_if_uncaught_exception);
|
||||
if( auto r = this->remote_try_catch_(
|
||||
[&]
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@ struct info
|
||||
template <class Ctx>
|
||||
leaf::result<int> f( Ctx & ctx )
|
||||
{
|
||||
leaf::context_activator active_context(ctx, leaf::on_deactivation::do_not_propagate);
|
||||
leaf::context_activator<> active_context(ctx, leaf::on_deactivation::do_not_propagate);
|
||||
return leaf::new_error( info<1>{1} );
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ int main()
|
||||
[&]
|
||||
{
|
||||
auto ctx = leaf::make_context(&handle_error);
|
||||
leaf::context_activator active_context(ctx, leaf::on_deactivation::propagate);
|
||||
leaf::context_activator<> active_context(ctx, leaf::on_deactivation::propagate);
|
||||
return f(ctx);
|
||||
},
|
||||
[&]( leaf::error_info const & error )
|
||||
|
||||
@@ -70,7 +70,7 @@ struct io_task_context
|
||||
asio::post( io_ctx,
|
||||
[=]() mutable
|
||||
{
|
||||
leaf::context_activator active_context(*err_ctx, leaf::on_deactivation::do_not_propagate);
|
||||
leaf::context_activator<> active_context(*err_ctx, leaf::on_deactivation::do_not_propagate);
|
||||
f();
|
||||
} );
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ struct info
|
||||
template <class Ctx>
|
||||
leaf::result<int> f( Ctx & ctx )
|
||||
{
|
||||
leaf::context_activator active_context(ctx, leaf::on_deactivation::do_not_propagate);
|
||||
leaf::context_activator<> active_context(ctx, leaf::on_deactivation::do_not_propagate);
|
||||
return leaf::new_error( info<1>{1} );
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ struct info
|
||||
template <class Ctx>
|
||||
void f( Ctx & ctx )
|
||||
{
|
||||
leaf::context_activator active_context(ctx, leaf::on_deactivation::do_not_propagate);
|
||||
leaf::context_activator<> active_context(ctx, leaf::on_deactivation::do_not_propagate);
|
||||
throw leaf::exception(std::exception(), info<1>{1});
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ struct info
|
||||
template <class Ctx>
|
||||
leaf::result<int> f( Ctx & ctx )
|
||||
{
|
||||
leaf::context_activator active_context(ctx, leaf::on_deactivation::do_not_propagate);
|
||||
leaf::context_activator<> active_context(ctx, leaf::on_deactivation::do_not_propagate);
|
||||
return leaf::new_error( info<1>{1} );
|
||||
}
|
||||
|
||||
|
||||
@@ -406,7 +406,7 @@ int main()
|
||||
|
||||
{ // error move -> copy
|
||||
leaf::context<e_err> ctx;
|
||||
leaf::context_activator active_context(ctx, leaf::on_deactivation::do_not_propagate);
|
||||
leaf::context_activator<> active_context(ctx, leaf::on_deactivation::do_not_propagate);
|
||||
leaf::result<val> r1 = leaf::new_error( e_err { } );
|
||||
BOOST_TEST(!r1);
|
||||
BOOST_TEST_EQ(err::count, 1);
|
||||
@@ -419,7 +419,7 @@ int main()
|
||||
BOOST_TEST_EQ(val::count, 0);
|
||||
{ // error copy -> copy
|
||||
leaf::context<e_err> ctx;
|
||||
leaf::context_activator active_context(ctx, leaf::on_deactivation::do_not_propagate);
|
||||
leaf::context_activator<> active_context(ctx, leaf::on_deactivation::do_not_propagate);
|
||||
leaf::error_id err = leaf::new_error( e_err{ } );
|
||||
leaf::result<val> r1 = err;
|
||||
BOOST_TEST(!r1);
|
||||
@@ -434,7 +434,7 @@ int main()
|
||||
|
||||
{ // error move -> move
|
||||
leaf::context<e_err> ctx;
|
||||
leaf::context_activator active_context(ctx, leaf::on_deactivation::do_not_propagate);
|
||||
leaf::context_activator<> active_context(ctx, leaf::on_deactivation::do_not_propagate);
|
||||
leaf::result<val> r1 = leaf::new_error( e_err { } );
|
||||
BOOST_TEST(!r1);
|
||||
BOOST_TEST_EQ(err::count, 1);
|
||||
@@ -447,7 +447,7 @@ int main()
|
||||
BOOST_TEST_EQ(val::count, 0);
|
||||
{ // error copy -> move
|
||||
leaf::context<e_err> ctx;
|
||||
leaf::context_activator active_context(ctx, leaf::on_deactivation::propagate);
|
||||
leaf::context_activator<> active_context(ctx, leaf::on_deactivation::propagate);
|
||||
leaf::error_id err = leaf::new_error( e_err{ } );
|
||||
leaf::result<val> r1 = err;
|
||||
BOOST_TEST(!r1);
|
||||
@@ -462,7 +462,7 @@ int main()
|
||||
|
||||
{ // error move -> assign copy
|
||||
leaf::context<e_err> ctx;
|
||||
leaf::context_activator active_context(ctx, leaf::on_deactivation::propagate);
|
||||
leaf::context_activator<> active_context(ctx, leaf::on_deactivation::propagate);
|
||||
leaf::result<val> r1 = leaf::new_error( e_err { } );
|
||||
BOOST_TEST(!r1);
|
||||
BOOST_TEST_EQ(err::count, 1);
|
||||
@@ -475,7 +475,7 @@ int main()
|
||||
BOOST_TEST_EQ(val::count, 0);
|
||||
{ // error copy -> assign copy
|
||||
leaf::context<e_err> ctx;
|
||||
leaf::context_activator active_context(ctx, leaf::on_deactivation::propagate);
|
||||
leaf::context_activator<> active_context(ctx, leaf::on_deactivation::propagate);
|
||||
leaf::error_id err = leaf::new_error( e_err{ } );
|
||||
leaf::result<val> r1 = err;
|
||||
BOOST_TEST(!r1);
|
||||
@@ -490,7 +490,7 @@ int main()
|
||||
|
||||
{ // error move -> assign move
|
||||
leaf::context<e_err> ctx;
|
||||
leaf::context_activator active_context(ctx, leaf::on_deactivation::propagate);
|
||||
leaf::context_activator<> active_context(ctx, leaf::on_deactivation::propagate);
|
||||
leaf::result<val> r1 = leaf::new_error( e_err { } );
|
||||
BOOST_TEST(!r1);
|
||||
BOOST_TEST_EQ(err::count, 1);
|
||||
@@ -508,7 +508,7 @@ int main()
|
||||
BOOST_TEST_EQ(val::count, 0);
|
||||
{ // error copy -> assign move
|
||||
leaf::context<e_err> ctx;
|
||||
leaf::context_activator active_context(ctx, leaf::on_deactivation::propagate);
|
||||
leaf::context_activator<> active_context(ctx, leaf::on_deactivation::propagate);
|
||||
leaf::error_id err = leaf::new_error( e_err{ } );
|
||||
leaf::result<val> r1 = err;
|
||||
BOOST_TEST(!r1);
|
||||
@@ -680,7 +680,7 @@ int main()
|
||||
|
||||
{ // void error move -> copy
|
||||
leaf::context<e_err> ctx;
|
||||
leaf::context_activator active_context(ctx, leaf::on_deactivation::do_not_propagate);
|
||||
leaf::context_activator<> active_context(ctx, leaf::on_deactivation::do_not_propagate);
|
||||
leaf::result<void> r1 = leaf::new_error( e_err { } );
|
||||
BOOST_TEST(!r1);
|
||||
BOOST_TEST_EQ(err::count, 1);
|
||||
@@ -691,7 +691,7 @@ int main()
|
||||
BOOST_TEST_EQ(err::count, 0);
|
||||
{ // void error copy -> copy
|
||||
leaf::context<e_err> ctx;
|
||||
leaf::context_activator active_context(ctx, leaf::on_deactivation::do_not_propagate);
|
||||
leaf::context_activator<> active_context(ctx, leaf::on_deactivation::do_not_propagate);
|
||||
leaf::error_id err = leaf::new_error( e_err{ } );
|
||||
leaf::result<void> r1 = err;
|
||||
BOOST_TEST(!r1);
|
||||
@@ -704,7 +704,7 @@ int main()
|
||||
|
||||
{ // void error move -> move
|
||||
leaf::context<e_err> ctx;
|
||||
leaf::context_activator active_context(ctx, leaf::on_deactivation::do_not_propagate);
|
||||
leaf::context_activator<> active_context(ctx, leaf::on_deactivation::do_not_propagate);
|
||||
leaf::result<void> r1 = leaf::new_error( e_err { } );
|
||||
BOOST_TEST(!r1);
|
||||
BOOST_TEST_EQ(err::count, 1);
|
||||
@@ -715,7 +715,7 @@ int main()
|
||||
BOOST_TEST_EQ(err::count, 0);
|
||||
{ // void error copy -> move
|
||||
leaf::context<e_err> ctx;
|
||||
leaf::context_activator active_context(ctx, leaf::on_deactivation::propagate);
|
||||
leaf::context_activator<> active_context(ctx, leaf::on_deactivation::propagate);
|
||||
leaf::error_id err = leaf::new_error( e_err{ } );
|
||||
leaf::result<void> r1 = err;
|
||||
BOOST_TEST(!r1);
|
||||
@@ -728,7 +728,7 @@ int main()
|
||||
|
||||
{ // void error move -> assign copy
|
||||
leaf::context<e_err> ctx;
|
||||
leaf::context_activator active_context(ctx, leaf::on_deactivation::propagate);
|
||||
leaf::context_activator<> active_context(ctx, leaf::on_deactivation::propagate);
|
||||
leaf::result<void> r1 = leaf::new_error( e_err { } );
|
||||
BOOST_TEST(!r1);
|
||||
BOOST_TEST_EQ(err::count, 1);
|
||||
@@ -739,7 +739,7 @@ int main()
|
||||
BOOST_TEST_EQ(err::count, 0);
|
||||
{ // void error copy -> assign copy
|
||||
leaf::context<e_err> ctx;
|
||||
leaf::context_activator active_context(ctx, leaf::on_deactivation::propagate);
|
||||
leaf::context_activator<> active_context(ctx, leaf::on_deactivation::propagate);
|
||||
leaf::error_id err = leaf::new_error( e_err{ } );
|
||||
leaf::result<void> r1 = err;
|
||||
BOOST_TEST(!r1);
|
||||
@@ -752,7 +752,7 @@ int main()
|
||||
|
||||
{ // void error move -> assign move
|
||||
leaf::context<e_err> ctx;
|
||||
leaf::context_activator active_context(ctx, leaf::on_deactivation::propagate);
|
||||
leaf::context_activator<> active_context(ctx, leaf::on_deactivation::propagate);
|
||||
leaf::result<void> r1 = leaf::new_error( e_err { } );
|
||||
BOOST_TEST(!r1);
|
||||
BOOST_TEST_EQ(err::count, 1);
|
||||
@@ -764,7 +764,7 @@ int main()
|
||||
BOOST_TEST_EQ(err::count, 0);
|
||||
{ // void error copy -> assign move
|
||||
leaf::context<e_err> ctx;
|
||||
leaf::context_activator active_context(ctx, leaf::on_deactivation::propagate);
|
||||
leaf::context_activator<> active_context(ctx, leaf::on_deactivation::propagate);
|
||||
leaf::error_id err = leaf::new_error( e_err{ } );
|
||||
leaf::result<void> r1 = err;
|
||||
BOOST_TEST(!r1);
|
||||
|
||||
Reference in New Issue
Block a user