MCPcopy Create free account
hub / github.com/boostorg/leaf / context

Class context

include/boost/leaf/context.hpp:320–387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

318
319template <class... E>
320class context final:
321 public detail::context_base
322{
323 context( context const & ) = delete;
324 context & operator=( context const & ) = delete;
325
326 using Tup = detail::deduce_e_tuple<E...>;
327 Tup tup_;
328 bool is_active_;
329
330#if !defined(BOOST_LEAF_NO_THREADS) && !defined(NDEBUG)
331 std::thread::id thread_id_;
332#endif
333
334 class raii_deactivator
335 {
336 raii_deactivator( raii_deactivator const & ) = delete;
337 raii_deactivator & operator=( raii_deactivator const & ) = delete;
338 context * ctx_;
339 public:
340 explicit BOOST_LEAF_CONSTEXPR BOOST_LEAF_ALWAYS_INLINE raii_deactivator(context & ctx) noexcept:
341 ctx_(ctx.is_active() ? nullptr : &ctx)
342 {
343 if( ctx_ )
344 ctx_->activate();
345 }
346#if __cplusplus < 201703L
347 BOOST_LEAF_CONSTEXPR BOOST_LEAF_ALWAYS_INLINE raii_deactivator( raii_deactivator && x ) noexcept:
348 ctx_(x.ctx_)
349 {
350 x.ctx_ = nullptr;
351 }
352#endif
353 BOOST_LEAF_ALWAYS_INLINE ~raii_deactivator() noexcept
354 {
355 if( ctx_ && ctx_->is_active() )
356 ctx_->deactivate();
357 }
358 };
359
360#if BOOST_LEAF_CFG_CAPTURE
361 void serialize_to_( detail::encoder & e, error_id id ) const override
362 {
363 detail::tuple_for_each<std::tuple_size<Tup>::value, Tup>::serialize_to(e, &tup_, id);
364 if( parent_ )
365 parent_->serialize_to_(e, id);
366 }
367#endif
368
369public:
370
371 template <class Encoder>
372 void serialize_to( Encoder & e, error_id id ) const
373 {
374 detail::tuple_for_each<std::tuple_size<Tup>::value, Tup>::serialize_to(e, &tup_, id);
375#if BOOST_LEAF_CFG_CAPTURE
376 if( parent_ )
377 parent_->serialize_to_(e, id);

Callers

nothing calls this directly

Calls 1

context_baseClass · 0.85

Tested by

no test coverage detected