From b65362d465079dde5532dafe5ff128ab9725846f Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Thu, 26 Sep 2024 20:33:56 -0700 Subject: [PATCH] Reverting changes --- example/error_log.cpp | 42 ++++++++--------- example/error_trace.cpp | 42 ++++++++--------- example/lua_callback_result.cpp | 42 ++++++++--------- example/print_file/print_file_leaf_result.cpp | 42 ++++++++--------- .../print_file/print_file_system_result.cpp | 46 +++++++++---------- example/print_half.cpp | 42 ++++++++--------- example/try_capture_all_result.cpp | 42 ++++++++--------- test/Jamfile.v2 | 4 +- test/error_code_test.cpp | 4 -- 9 files changed, 150 insertions(+), 156 deletions(-) diff --git a/example/error_log.cpp b/example/error_log.cpp index c5b8e438..ea19e8cb 100644 --- a/example/error_log.cpp +++ b/example/error_log.cpp @@ -12,27 +12,6 @@ // not captured, only printed. #include - -#ifdef BOOST_LEAF_NO_EXCEPTIONS - -namespace boost -{ - [[noreturn]] void throw_exception( std::exception const & e ) - { - std::terminate(); - } - - struct source_location; - [[noreturn]] void throw_exception( std::exception const & e, boost::source_location const & ) - { - throw_exception(e); - } -} - -#endif - -//////////////////////////////////////// - #include #include @@ -146,3 +125,24 @@ int main() } ); return 0; } + +//////////////////////////////////////// + +#ifdef BOOST_LEAF_NO_EXCEPTIONS + +namespace boost +{ + [[noreturn]] void throw_exception( std::exception const & e ) + { + std::cerr << "Terminating due to a C++ exception under BOOST_LEAF_NO_EXCEPTIONS: " << e.what(); + std::terminate(); + } + + struct source_location; + [[noreturn]] void throw_exception( std::exception const & e, boost::source_location const & ) + { + throw_exception(e); + } +} + +#endif diff --git a/example/error_trace.cpp b/example/error_trace.cpp index 4d86423e..c3299b95 100644 --- a/example/error_trace.cpp +++ b/example/error_trace.cpp @@ -13,27 +13,6 @@ // recorded in a std::deque, rather than just printed in-place. #include - -#ifdef BOOST_LEAF_NO_EXCEPTIONS - -namespace boost -{ - [[noreturn]] void throw_exception( std::exception const & e ) - { - std::terminate(); - } - - struct source_location; - [[noreturn]] void throw_exception( std::exception const & e, boost::source_location const & ) - { - throw_exception(e); - } -} - -#endif - -//////////////////////////////////////// - #include #include #include @@ -146,3 +125,24 @@ int main() } ); return 0; } + +//////////////////////////////////////// + +#ifdef BOOST_LEAF_NO_EXCEPTIONS + +namespace boost +{ + [[noreturn]] void throw_exception( std::exception const & e ) + { + std::cerr << "Terminating due to a C++ exception under BOOST_LEAF_NO_EXCEPTIONS: " << e.what(); + std::terminate(); + } + + struct source_location; + [[noreturn]] void throw_exception( std::exception const & e, boost::source_location const & ) + { + throw_exception(e); + } +} + +#endif diff --git a/example/lua_callback_result.cpp b/example/lua_callback_result.cpp index 8a562d98..fc7a046f 100644 --- a/example/lua_callback_result.cpp +++ b/example/lua_callback_result.cpp @@ -5,32 +5,11 @@ // This is a simple program that shows how to report error objects out of a // C-callback, converting them to leaf::result as soon as controlreaches C++. -#include - -#ifdef BOOST_LEAF_NO_EXCEPTIONS - -namespace boost -{ - [[noreturn]] void throw_exception( std::exception const & e ) - { - std::terminate(); - } - - struct source_location; - [[noreturn]] void throw_exception( std::exception const & e, boost::source_location const & ) - { - throw_exception(e); - } -} - -#endif - -//////////////////////////////////////// - extern "C" { #include "lua.h" #include "lauxlib.h" } +#include #include #include #include @@ -174,3 +153,22 @@ int main() return 0; } + +#ifdef BOOST_LEAF_NO_EXCEPTIONS + +namespace boost +{ + [[noreturn]] void throw_exception( std::exception const & e ) + { + std::cerr << "Terminating due to a C++ exception under BOOST_LEAF_NO_EXCEPTIONS: " << e.what(); + std::terminate(); + } + + struct source_location; + [[noreturn]] void throw_exception( std::exception const & e, boost::source_location const & ) + { + throw_exception(e); + } +} + +#endif diff --git a/example/print_file/print_file_leaf_result.cpp b/example/print_file/print_file_leaf_result.cpp index 37834f9d..a32ec549 100644 --- a/example/print_file/print_file_leaf_result.cpp +++ b/example/print_file/print_file_leaf_result.cpp @@ -10,27 +10,6 @@ // does use exception handling is in print_file_exceptions.cpp. #include - -#ifdef BOOST_LEAF_NO_EXCEPTIONS - -namespace boost -{ - [[noreturn]] void throw_exception( std::exception const & e ) - { - std::terminate(); - } - - struct source_location; - [[noreturn]] void throw_exception( std::exception const & e, boost::source_location const & ) - { - throw_exception(e); - } -} - -#endif - -//////////////////////////////////////// - #include #include #include @@ -223,3 +202,24 @@ result file_read( FILE & f, void * buf, std::size_t size ) return { }; } + +//////////////////////////////////////// + +#ifdef BOOST_LEAF_NO_EXCEPTIONS + +namespace boost +{ + [[noreturn]] void throw_exception( std::exception const & e ) + { + std::cerr << "Terminating due to a C++ exception under BOOST_LEAF_NO_EXCEPTIONS: " << e.what(); + std::terminate(); + } + + struct source_location; + [[noreturn]] void throw_exception( std::exception const & e, boost::source_location const & ) + { + throw_exception(e); + } +} + +#endif diff --git a/example/print_file/print_file_system_result.cpp b/example/print_file/print_file_system_result.cpp index b36ef09b..b5addfb5 100644 --- a/example/print_file/print_file_system_result.cpp +++ b/example/print_file/print_file_system_result.cpp @@ -11,27 +11,6 @@ #include - -#ifdef BOOST_LEAF_NO_EXCEPTIONS - -namespace boost -{ - [[noreturn]] void throw_exception( std::exception const & e ) - { - std::terminate(); - } - - struct source_location; - [[noreturn]] void throw_exception( std::exception const & e, boost::source_location const & ) - { - throw_exception(e); - } -} - -#endif - -//////////////////////////////////////// - #include #include #include @@ -53,12 +32,12 @@ enum error_code template -using result = boost::system::result; +using result = boost::system::result; // To enable LEAF to work with boost::system::result, we need to specialize the // is_result_type template: namespace boost { namespace leaf { - template struct is_result_type>: std::true_type { }; + template struct is_result_type>: std::true_type { }; } } @@ -231,3 +210,24 @@ result file_read( FILE & f, void * buf, std::size_t size ) return { }; } + +//////////////////////////////////////// + +#ifdef BOOST_LEAF_NO_EXCEPTIONS + +namespace boost +{ + BOOST_NORETURN void throw_exception( std::exception const & e ) + { + std::cerr << "Terminating due to a C++ exception under BOOST_LEAF_NO_EXCEPTIONS: " << e.what(); + std::terminate(); + } + + struct source_location; + BOOST_NORETURN void throw_exception( std::exception const & e, boost::source_location const & ) + { + throw_exception(e); + } +} + +#endif diff --git a/example/print_half.cpp b/example/print_half.cpp index 8e3d0228..1211d277 100644 --- a/example/print_half.cpp +++ b/example/print_half.cpp @@ -6,27 +6,6 @@ // https://github.com/ned14/outcome/blob/master/doc/src/snippets/using_result.cpp #include - -#ifdef BOOST_LEAF_NO_EXCEPTIONS - -namespace boost -{ - [[noreturn]] void throw_exception( std::exception const & e ) - { - std::terminate(); - } - - struct source_location; - [[noreturn]] void throw_exception( std::exception const & e, boost::source_location const & ) - { - throw_exception(e); - } -} - -#endif - -//////////////////////////////////////// - #include #include #include @@ -117,3 +96,24 @@ int main( int argc, char const * argv[] ) return 3; } ); } + +//////////////////////////////////////// + +#ifdef BOOST_LEAF_NO_EXCEPTIONS + +namespace boost +{ + [[noreturn]] void throw_exception( std::exception const & e ) + { + std::cerr << "Terminating due to a C++ exception under BOOST_LEAF_NO_EXCEPTIONS: " << e.what(); + std::terminate(); + } + + struct source_location; + [[noreturn]] void throw_exception( std::exception const & e, boost::source_location const & ) + { + throw_exception(e); + } +} + +#endif diff --git a/example/try_capture_all_result.cpp b/example/try_capture_all_result.cpp index dda27778..0a06685b 100644 --- a/example/try_capture_all_result.cpp +++ b/example/try_capture_all_result.cpp @@ -21,27 +21,6 @@ int main() #else #include - -#ifdef BOOST_LEAF_NO_EXCEPTIONS - -namespace boost -{ - [[noreturn]] void throw_exception( std::exception const & e ) - { - std::terminate(); - } - - struct source_location; - [[noreturn]] void throw_exception( std::exception const & e, boost::source_location const & ) - { - throw_exception(e); - } -} - -#endif - -//////////////////////////////////////// - #include #include #include @@ -124,4 +103,25 @@ int main() } } +//////////////////////////////////////// + +#ifdef BOOST_LEAF_NO_EXCEPTIONS + +namespace boost +{ + [[noreturn]] void throw_exception( std::exception const & e ) + { + std::cerr << "Terminating due to a C++ exception under BOOST_LEAF_NO_EXCEPTIONS: " << e.what(); + std::terminate(); + } + + struct source_location; + [[noreturn]] void throw_exception( std::exception const & e, boost::source_location const & ) + { + throw_exception(e); + } +} + +#endif + #endif diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 83b9ccd1..85ed6eab 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -70,7 +70,7 @@ run diagnostics_test4.cpp ; run diagnostics_test5.cpp ; run e_errno_test.cpp ; run e_LastError_test.cpp ; -run error_code_test.cpp : : : 1z:no:no ; +run error_code_test.cpp ; run error_id_test.cpp ; run exception_test.cpp ; run exception_to_result_test.cpp ; @@ -159,5 +159,5 @@ exe error_trace : ../example/error_trace.cpp ; exe exception_to_result : ../example/exception_to_result.cpp : off:no ; exe print_file_exceptions : ../example/print_file/print_file_exceptions.cpp : off:no ; exe print_file_leaf_result : ../example/print_file/print_file_leaf_result.cpp ; -exe print_file_system_result : ../example/print_file/print_file_system_result.cpp : 11:no 14:no 1z:no leaf_debug_embedded:no leaf_release_embedded:no ; +exe print_file_system_result : ../example/print_file/print_file_system_result.cpp : 11:no 14:no leaf_debug_embedded:no leaf_release_embedded:no ; exe print_half : ../example/print_half.cpp ; diff --git a/test/error_code_test.cpp b/test/error_code_test.cpp index 9474c07d..668445bf 100644 --- a/test/error_code_test.cpp +++ b/test/error_code_test.cpp @@ -29,7 +29,6 @@ int main() #include "boost/system/result.hpp" namespace boost { namespace leaf { - template struct is_result_type>: std::true_type { }; template struct is_result_type>: std::true_type { }; } } @@ -618,9 +617,6 @@ int main() test_void>(); test_void>(); test>(); -#if __cplusplus >= 201703L - test>(); -#endif return boost::report_errors(); }