diff --git a/include/boost/leaf/error.hpp b/include/boost/leaf/error.hpp index 7f5dc9d..9390ae0 100644 --- a/include/boost/leaf/error.hpp +++ b/include/boost/leaf/error.hpp @@ -68,63 +68,6 @@ namespace boost { namespace leaf { -class BOOST_LEAF_SYMBOL_VISIBLE error_id; - -namespace leaf_detail -{ - struct BOOST_LEAF_SYMBOL_VISIBLE tls_tag_id_factory_current_id; - - template - struct BOOST_LEAF_SYMBOL_VISIBLE id_factory - { - static atomic_unsigned_int counter; - - BOOST_LEAF_CONSTEXPR static unsigned generate_next_id() noexcept - { - auto id = (counter+=4); - BOOST_LEAF_ASSERT((id&3)==1); - return id; - } - }; - - template - atomic_unsigned_int id_factory::counter(unsigned(-3)); - - inline int current_id() noexcept - { - unsigned id = tls::read_uint(); - BOOST_LEAF_ASSERT(id==0 || (id&3)==1); - return int(id); - } - - inline int new_id() noexcept - { - unsigned id = id_factory<>::generate_next_id(); - tls::write_uint(id); - return int(id); - } - - struct inject_loc - { - char const * const file; - int const line; - char const * const fn; - - template - friend T operator+( inject_loc loc, T && x ) noexcept - { - x.load_source_location_(loc.file, loc.line, loc.fn); - return std::move(x); - } - }; -} - -} } - -//////////////////////////////////////// - -namespace boost { namespace leaf { - struct BOOST_LEAF_SYMBOL_VISIBLE e_source_location { char const * file; @@ -138,11 +81,9 @@ struct BOOST_LEAF_SYMBOL_VISIBLE e_source_location } }; -} } - //////////////////////////////////////// -namespace boost { namespace leaf { +class BOOST_LEAF_SYMBOL_VISIBLE error_id; namespace leaf_detail { @@ -207,14 +148,10 @@ namespace leaf_detail }; } -} } - //////////////////////////////////////// #if BOOST_LEAF_CFG_CAPTURE -namespace boost { namespace leaf { - namespace leaf_detail { class BOOST_LEAF_SYMBOL_VISIBLE dynamic_allocator: @@ -485,14 +422,10 @@ namespace leaf_detail } } -} } - #endif //////////////////////////////////////// -namespace boost { namespace leaf { - namespace leaf_detail { template @@ -570,12 +503,8 @@ namespace leaf_detail } } -} } - //////////////////////////////////////// -namespace boost { namespace leaf { - namespace leaf_detail { template ::arity> @@ -612,13 +541,58 @@ namespace leaf_detail }; } -} } - //////////////////////////////////////// -#if BOOST_LEAF_CFG_STD_SYSTEM_ERROR +namespace leaf_detail +{ + struct BOOST_LEAF_SYMBOL_VISIBLE tls_tag_id_factory_current_id; -namespace boost { namespace leaf { + template + struct BOOST_LEAF_SYMBOL_VISIBLE id_factory + { + static atomic_unsigned_int counter; + + BOOST_LEAF_CONSTEXPR static unsigned generate_next_id() noexcept + { + auto id = (counter+=4); + BOOST_LEAF_ASSERT((id&3)==1); + return id; + } + }; + + template + atomic_unsigned_int id_factory::counter(unsigned(-3)); + + inline int current_id() noexcept + { + unsigned id = tls::read_uint(); + BOOST_LEAF_ASSERT(id==0 || (id&3)==1); + return int(id); + } + + inline int new_id() noexcept + { + unsigned id = id_factory<>::generate_next_id(); + tls::write_uint(id); + return int(id); + } + + struct inject_loc + { + char const * const file; + int const line; + char const * const fn; + + template + friend T operator+( inject_loc loc, T && x ) noexcept + { + x.load_source_location_(loc.file, loc.line, loc.fn); + return std::move(x); + } + }; +} + +#if BOOST_LEAF_CFG_STD_SYSTEM_ERROR namespace leaf_detail { @@ -670,14 +644,10 @@ inline bool is_error_id( std::error_code const & ec ) noexcept return res; } -} } - #endif //////////////////////////////////////// -namespace boost { namespace leaf { - namespace leaf_detail { BOOST_LEAF_CONSTEXPR error_id make_error_id(int) noexcept; @@ -857,12 +827,8 @@ public: } }; -} } - //////////////////////////////////////////// -namespace boost { namespace leaf { - template struct is_result_type: std::false_type { diff --git a/include/boost/leaf/exception.hpp b/include/boost/leaf/exception.hpp index dd2c71e..d49ab19 100644 --- a/include/boost/leaf/exception.hpp +++ b/include/boost/leaf/exception.hpp @@ -102,12 +102,8 @@ namespace leaf_detail }; } -} } - //////////////////////////////////////// -namespace boost { namespace leaf { - namespace leaf_detail { inline void enforce_std_exception( std::exception const & ) noexcept { }