cppx-core
exception-propagation.hpp
Go to the documentation of this file.
1 #pragma once // Source encoding: UTF-8 with BOM (π is a lowercase Greek "pi").
2 
3 #include <cppx-core/language/syntax/macro-use.hpp> // CPPX_USE_STD
4 
5 #include <exception> // std::(rethrow_exception)
6 #include <stdexcept> // std::(exception_ptr)
7 
8 namespace cppx
9 {
10  CPPX_USE_STD( exception_ptr, rethrow_exception );
11 
13  namespace impl
14  {
15  inline auto stored_ptr()
16  -> exception_ptr&
17  {
18  static exception_ptr the_stored_ptr;
19  return the_stored_ptr;
20  }
21  }
23 
24  inline auto replace_stored_x_with( const exception_ptr& p )
25  -> exception_ptr
26  {
27  exception_ptr original = impl::stored_ptr();
28  impl::stored_ptr() = p;
29  return original;
30  }
31 
32  inline void clear_stored_x()
33  {
34  impl::stored_ptr() = nullptr;
35  }
36 
37  inline void rethrow_any_stored_x()
38  {
39  const exception_ptr p = impl::stored_ptr();
40  if( p != nullptr )
41  {
42  impl::stored_ptr() = nullptr;
43  rethrow_exception( p );
44  }
45  }
46 } // namespace cppx
auto replace_stored_x_with(const exception_ptr &p) -> exception_ptr
CPPX_USE_STD(basic_string, basic_string_view, bitset, char_traits, size)
void clear_stored_x()
void rethrow_any_stored_x()
Macros for generating more concise and clear using statements, primarily $use_cppx and $use_std,...