From e032a0b4f7ffd31306618c711a0d64f61c3c93b9 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Thu, 3 Jan 2019 17:25:09 -0800 Subject: [PATCH] member handle_error --- .travis.yml | 1 + example/capture_eh.cpp | 2 +- example/capture_result.cpp | 2 +- example/lua_callback_result.cpp | 2 +- example/print_file_eh.cpp | 6 +- example/print_file_result.cpp | 10 +- example/print_half.cpp | 7 +- example/return_exception.cpp | 2 +- include/boost/leaf/diagnostic_output.hpp | 53 ----------- .../diagnostic_output_current_exception.hpp | 9 +- include/boost/leaf/error.hpp | 29 ++++-- include/boost/leaf/error_capture.hpp | 74 ++++++--------- include/boost/leaf/exception.hpp | 19 ++-- include/boost/leaf/exception_capture.hpp | 4 +- include/boost/leaf/expect.hpp | 95 ++++++++++++------- include/boost/leaf/result.hpp | 74 ++++----------- test/basic_test.cpp | 36 +++---- test/defer_test.1.cpp | 2 +- test/defer_test.2.cpp | 4 +- test/defer_test.3.cpp | 2 +- test/defer_test.4.cpp | 2 +- test/defer_test.5.cpp | 2 +- test/defer_test.6.cpp | 2 +- test/defer_test.7.cpp | 2 +- test/defer_test.8.cpp | 2 +- test/diagnostic_output_test.cpp | 2 +- test/error_capture_test.1.cpp | 16 ++-- test/error_capture_test.2.cpp | 22 ++--- test/error_test.cpp | 12 +-- test/exception_capture_test.cpp | 2 +- test/exception_test.1.cpp | 8 +- test/exception_test.2.cpp | 8 +- test/expect_fail_test.1.cpp | 2 +- test/expect_fail_test.2.cpp | 2 +- test/expect_test.1.cpp | 2 +- test/expect_test.2.cpp | 2 +- test/expect_test.3.cpp | 2 +- test/expect_test.4.cpp | 18 ++-- test/expect_test.5.cpp | 12 +-- test/multiple_errors_test.cpp | 4 +- test/preload_test.1.cpp | 4 +- test/preload_test.2.cpp | 2 +- test/preload_test.3.cpp | 2 +- test/preload_test.4.cpp | 2 +- test/preload_test.5.cpp | 2 +- test/preload_test.6.cpp | 2 +- test/preload_test.7.cpp | 2 +- test/result_capture_test.cpp | 2 +- test/result_test.1.cpp | 8 +- test/result_test.2.cpp | 32 +++---- test/result_test.3.cpp | 2 +- test/result_test.4.cpp | 2 +- test/result_test.5.cpp | 22 ++--- test/result_test.6.cpp | 18 ++-- test/result_void_capture_test.cpp | 2 +- 55 files changed, 303 insertions(+), 358 deletions(-) delete mode 100644 include/boost/leaf/diagnostic_output.hpp diff --git a/.travis.yml b/.travis.yml index f1acb82..edcbee9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,7 @@ branches: only: - master - develop + - feature/* env: matrix: diff --git a/example/capture_eh.cpp b/example/capture_eh.cpp index a778602..725b4ce 100644 --- a/example/capture_eh.cpp +++ b/example/capture_eh.cpp @@ -91,7 +91,7 @@ int main() catch( failure const & e ) { //Failure! Handle the error, print failure info. - handle_exception( exp, e, + exp.handle_exception( e, [ ] ( e_failure_info1 const & v1, e_failure_info2 const & v2, e_thread_id const & tid ) { std::cerr << "Error in thread " << tid.value << "! failure_info1: " << v1.value << ", failure_info2: " << v2.value << std::endl; diff --git a/example/capture_result.cpp b/example/capture_result.cpp index 0fabf15..f8a555e 100644 --- a/example/capture_result.cpp +++ b/example/capture_result.cpp @@ -81,7 +81,7 @@ int main() else { //Failure! Handle error, print failure info. - bool matched = handle_error( exp, r, + bool matched = exp.handle_error( r, [ ] ( e_failure_info1 const & v1, e_failure_info2 const & v2, e_thread_id const & tid ) { std::cerr << "Error in thread " << tid.value << "! failure_info1: " << v1.value << ", failure_info2: " << v2.value << std::endl; diff --git a/example/lua_callback_result.cpp b/example/lua_callback_result.cpp index 3c63fdb..b0042b1 100644 --- a/example/lua_callback_result.cpp +++ b/example/lua_callback_result.cpp @@ -119,7 +119,7 @@ int main() noexcept std::cout << "do_work succeeded, answer=" << *r << '\n'; else { - bool matched = handle_error( exp, r, + bool matched = exp.handle_error( r, //Handle e_do_work failures: [ ]( do_work_error_code e ) diff --git a/example/print_file_eh.cpp b/example/print_file_eh.cpp index 2313c1b..1a5e25e 100644 --- a/example/print_file_eh.cpp +++ b/example/print_file_eh.cpp @@ -123,7 +123,7 @@ int main( int argc, char const * argv[ ] ) //are associated with the error value stored in e. If no function can be matched, //handle_exception returns false. Otherwise the matched function is invoked with //the corresponding available error objects. - leaf::handle_exception( exp, e, + exp.handle_exception( e, [ ] ( e_file_name const & fn, e_errno const & errn ) { @@ -142,7 +142,7 @@ int main( int argc, char const * argv[ ] ) //e_file_name and e_errno, associated with e, are avialable in exp; if not, it will //next check if just e_errno is available; and if not, the last function (which //takes no arguments) will always match to print a generic error message. - leaf::handle_exception( exp, e, + exp.handle_exception( e, [ ] ( e_file_name const & fn, e_errno const & errn ) { @@ -165,7 +165,7 @@ int main( int argc, char const * argv[ ] ) catch( std::ostream::failure const & e ) { //Report failure to write to std::cout, print the relevant errno. - leaf::handle_exception( exp, e, + exp.handle_exception( e, [ ] ( e_errno const & errn ) { diff --git a/example/print_file_result.cpp b/example/print_file_result.cpp index 1681305..1948072 100644 --- a/example/print_file_result.cpp +++ b/example/print_file_result.cpp @@ -125,7 +125,7 @@ int main( int argc, char const * argv[ ] ) else { //Probe exp for the error_code object associated with the error stored in r. - switch( auto ec = *leaf::peek(exp,r) ) + switch( auto ec = *exp.peek(r) ) { case input_file_open_error: { @@ -134,7 +134,7 @@ int main( int argc, char const * argv[ ] ) //are associated with the error value stored in r. If no function can be matched, //handle_error returns false. Otherwise the matched function is invoked with //the matching corresponding error objects. - bool matched = leaf::handle_error( exp, r, + bool matched = exp.handle_error( r, [ ] ( e_file_name const & fn, e_errno const & errn ) { @@ -157,7 +157,7 @@ int main( int argc, char const * argv[ ] ) //e_file_name and e_errno, associated with r, are avialable in exp; if not, it will //next check if just e_errno is available; and if not, the last function (which //takes no arguments) will always match to print a generic error message. - bool matched = leaf::handle_error( exp, r, + bool matched = exp.handle_error( r, [ ] ( e_file_name const & fn, e_errno const & errn ) { @@ -182,7 +182,7 @@ int main( int argc, char const * argv[ ] ) case cout_error: { //Report failure to write to std::cout, print the relevant errno. - bool matched = leaf::handle_error( exp, r, + bool matched = exp.handle_error( r, [ ] ( e_errno const & errn ) { @@ -199,7 +199,7 @@ int main( int argc, char const * argv[ ] ) default: { std::cerr << "Unknown error code " << ec << ", cryptic information follows." << std::endl; //<7> - leaf::diagnostic_output(std::cerr,r); + r.diagnostic_output(std::cerr); return 5; } } diff --git a/example/print_half.cpp b/example/print_half.cpp index f0b1b22..201d293 100644 --- a/example/print_half.cpp +++ b/example/print_half.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -62,7 +61,7 @@ leaf::result print_half(const std::string& text) } else { - return leaf::handle_error( exp, r, + return exp.handle_error( r, [&]( ConversionErrc ec ) -> leaf::result { if( ec != ConversionErrc::TooLong ) @@ -84,7 +83,7 @@ int main( int argc, char const * argv[ ] ) } else { - return handle_error( exp, r, + return exp.handle_error( r, [ ]( ConversionErrc ec ) { switch(ec) @@ -104,7 +103,7 @@ int main( int argc, char const * argv[ ] ) //In this case, we print diagnostic information. Consider using leaf::unexpected_diagnostic_output in the //definition of exp. std::cerr << "Unknown error, cryptic diagnostic information follows." << std::endl; - leaf::diagnostic_output(std::cerr,r); + r.diagnostic_output(std::cerr); return 2; } ); } diff --git a/example/return_exception.cpp b/example/return_exception.cpp index 657fa06..88e3184 100644 --- a/example/return_exception.cpp +++ b/example/return_exception.cpp @@ -84,7 +84,7 @@ int main() continue; else { - leaf::handle_error( exp, r, + exp.handle_error( r, [ ]( error_a const & e ) { diff --git a/include/boost/leaf/diagnostic_output.hpp b/include/boost/leaf/diagnostic_output.hpp deleted file mode 100644 index eb3b75b..0000000 --- a/include/boost/leaf/diagnostic_output.hpp +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef BOOST_LEAF_7062AB340F9411E9A7CFDBC88C7F4AFC -#define BOOST_LEAF_7062AB340F9411E9A7CFDBC88C7F4AFC - -//Copyright (c) 2018 Emil Dotchevski -//Copyright (c) 2018 Second Spectrum, Inc. - -//Distributed under the Boost Software License, Version 1.0. (See accompanying -//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include - -namespace boost { namespace leaf { - - namespace leaf_detail - { - inline void slot_base::diagnostic_output( std::ostream & os, error const * e ) - { - for( slot_base const * p = first(); p; p=p->next_ ) - if( p->slot_diagnostic_output(os,e) ) - os << std::endl; - } - } - - inline void diagnostic_output( std::ostream & os, error const & e ) - { - os << "leaf::error serial number: " << e << std::endl; - leaf_detail::slot_base::diagnostic_output(os,&e); - } - - inline void diagnostic_output( std::ostream & os ) - { - leaf_detail::slot_base::diagnostic_output(os,0); - } - - template - class result; - - template - void diagnostic_output( std::ostream & os, result const & r ) - { - assert(!r); - if( r.which_==leaf_detail::result_variant::err ) - return diagnostic_output(os,r.err_); - else - { - assert(r.which_==leaf_detail::result_variant::cap); - return diagnostic_output(os,r.cap_); - } - } - -} } - -#endif diff --git a/include/boost/leaf/diagnostic_output_current_exception.hpp b/include/boost/leaf/diagnostic_output_current_exception.hpp index d2097cd..3ea08ca 100644 --- a/include/boost/leaf/diagnostic_output_current_exception.hpp +++ b/include/boost/leaf/diagnostic_output_current_exception.hpp @@ -8,7 +8,6 @@ //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include -#include #include namespace boost { namespace leaf { @@ -37,17 +36,17 @@ namespace boost { namespace leaf { { throw; } - catch( leaf_detail::captured_exception const & e ) + catch( leaf_detail::captured_exception const & ce ) { - diagnostic_output_(os,e); + ce.diagnostic_output(os); } catch( error const & e ) { - diagnostic_output(os,e); + e.diagnostic_output(os); } catch( ... ) { - diagnostic_output(os); + global_diagnostic_output(os); } } diff --git a/include/boost/leaf/error.hpp b/include/boost/leaf/error.hpp index 7a5cb66..a9b398f 100644 --- a/include/boost/leaf/error.hpp +++ b/include/boost/leaf/error.hpp @@ -188,19 +188,21 @@ namespace boost { namespace leaf { return e1.id_!=e2.id_; } + error propagate() const noexcept + { + return *this; + } + friend std::ostream & operator<<( std::ostream & os, error const & e ) { os << e.id_; return os; } - error propagate() const noexcept - { - return *this; - } - template error propagate( E && ... ) const noexcept; + + void diagnostic_output( std::ostream & os ) const; }; inline error next_error_value() noexcept @@ -239,7 +241,12 @@ namespace boost { namespace leaf { public: - static void diagnostic_output( std::ostream & os, error const * e ); + static void diagnostic_output( std::ostream & os, error const * e ) + { + for( slot_base const * p = first(); p; p=p->next_ ) + if( p->slot_diagnostic_output(os,e) ) + os << std::endl; + } protected: @@ -439,6 +446,16 @@ namespace boost { namespace leaf { return *this; } + inline void error::diagnostic_output( std::ostream & os ) const + { + os << "leaf::error serial number: " << *this << std::endl; + leaf_detail::slot_base::diagnostic_output(os,this); + } + + inline void global_diagnostic_output( std::ostream & os ) + { + leaf_detail::slot_base::diagnostic_output(os,0); + } } } #endif diff --git a/include/boost/leaf/error_capture.hpp b/include/boost/leaf/error_capture.hpp index d652a85..e61d084 100644 --- a/include/boost/leaf/error_capture.hpp +++ b/include/boost/leaf/error_capture.hpp @@ -13,14 +13,6 @@ namespace boost { namespace leaf { class error_capture; - template - typename leaf_detail::handler_pack_return_type::return_type handle_error( error_capture const &, F && ... ) noexcept; - - template - P const * peek( error_capture const & ) noexcept; - - void diagnostic_output( std::ostream &, error_capture const & ); - namespace leaf_detail { template @@ -29,10 +21,7 @@ namespace boost { namespace leaf { template struct all_available { - static bool check( error_capture const & cap ) noexcept - { - return peek(cap) && all_available::check(cap); - } + static bool check( error_capture const & cap ) noexcept; }; template <> @@ -87,16 +76,6 @@ namespace boost { namespace leaf { class error_capture { - template - friend typename leaf_detail::handler_pack_return_type::return_type handle_error( error_capture const &, F && ... ) noexcept; - - template - friend P const * leaf::peek( error_capture const & ) noexcept; - - friend void leaf::diagnostic_output( std::ostream &, error_capture const & ); - - //////////////////////////////////////// - class dynamic_store { mutable std::atomic refcount_; @@ -189,7 +168,7 @@ namespace boost { namespace leaf { using namespace leaf_detail; typedef typename handler_wrapper::return_type return_type; if( leaf_detail::all_available::type>::type...>::check(*this) ) - return std::make_pair(true, handler_wrapper(std::forward(f))( *leaf::peek::type>::type>(*this)... )); + return std::make_pair(true, handler_wrapper(std::forward(f))( *this->template peek::type>::type>()... )); else return std::make_pair(false, return_type(uhnandled_error::value(e_))); } @@ -283,30 +262,37 @@ namespace boost { namespace leaf { } return e_; } + + template + typename leaf_detail::handler_pack_return_type::return_type handle_error( F && ... f ) const noexcept + { + return this->find_handler_( std::forward(f)... ).second; + } + + template + P const * peek() const noexcept + { + if( *this ) + if( auto * opt = ds_->bind

() ) + if( opt->has_value() ) + return &opt->value(); + return 0; + } + + void diagnostic_output( std::ostream & os ) const + { + if( *this ) + ds_->diagnostic_output_(os); + } }; - //////////////////////////////////////// - - template - typename leaf_detail::handler_pack_return_type::return_type handle_error( error_capture const & ec, F && ... f ) noexcept + namespace leaf_detail { - return ec.find_handler_( std::forward(f)... ).second; - } - - template - P const * peek( error_capture const & e ) noexcept - { - if( e ) - if( auto * opt = e.ds_->bind

() ) - if( opt->has_value() ) - return &opt->value(); - return 0; - } - - inline void diagnostic_output( std::ostream & os, error_capture const & e ) - { - if( e ) - e.ds_->diagnostic_output_(os); + template + bool all_available::check( error_capture const & cap ) noexcept + { + return cap.template peek() && all_available::check(cap); + } } } } diff --git a/include/boost/leaf/exception.hpp b/include/boost/leaf/exception.hpp index e6c9f29..9ec7d55 100644 --- a/include/boost/leaf/exception.hpp +++ b/include/boost/leaf/exception.hpp @@ -21,28 +21,29 @@ namespace boost { namespace leaf { return next_error_value(); } - template - P const * peek( expect const & exp, std::exception const & ex ) noexcept + template + template + P const * expect::peek( std::exception const & ex ) const noexcept { - return peek

(exp,get_error(ex)); + return this->template peek

(get_error(ex)); } - template - void handle_exception( expect & exp, std::exception const & ex, F && ... f ) + template + template + void expect::handle_exception( std::exception const & ex, F && ... f ) const { - if( handle_error(exp,get_error(ex),f...) ) + if( this->handle_error(get_error(ex),f...) ) (void) error(); else throw; } - template - void diagnostic_output( std::ostream & os, expect const & exp, std::exception const & ex ) + inline void diagnostic_output( std::ostream & os, std::exception const & ex ) { os << "Exception dynamic type: " << leaf_detail::demangle(typeid(ex).name()) << std::endl << "std::exception::what(): " << ex.what() << std::endl; - diagnostic_output(os,exp,get_error(ex)); + get_error(ex).diagnostic_output(os); } } } diff --git a/include/boost/leaf/exception_capture.hpp b/include/boost/leaf/exception_capture.hpp index 2098d35..75c6c11 100644 --- a/include/boost/leaf/exception_capture.hpp +++ b/include/boost/leaf/exception_capture.hpp @@ -44,9 +44,9 @@ namespace boost { namespace leaf { std::rethrow_exception(ex_); } - friend void diagnostic_output_( std::ostream & os, captured_exception const & ce ) + void diagnostic_output( std::ostream & os ) const { - diagnostic_output(os,static_cast(ce)); + static_cast(this)->diagnostic_output(os); } }; diff --git a/include/boost/leaf/expect.hpp b/include/boost/leaf/expect.hpp index f5f049f..4b0b4b5 100644 --- a/include/boost/leaf/expect.hpp +++ b/include/boost/leaf/expect.hpp @@ -8,11 +8,16 @@ //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include +#include +#include namespace boost { namespace leaf { class error_capture; + template + class result; + namespace leaf_detail { template @@ -117,13 +122,6 @@ namespace boost { namespace leaf { template class expect; - template - typename leaf_detail::handler_pack_return_type::return_type handle_error( expect const &, error const &, F && ... ) noexcept; - - template - P const * peek( expect const &, error const & ) noexcept; - - template typename leaf_detail::dependent_type>::error_capture capture( expect &, error const & ); @@ -132,12 +130,6 @@ namespace boost { namespace leaf { { friend class error; - template - friend typename leaf_detail::handler_pack_return_type::return_type leaf::handle_error( expect const &, error const &, F && ... ) noexcept; - - template - friend P const * leaf::peek( expect const &, error const & ) noexcept; - template friend typename leaf_detail::dependent_type>::error_capture leaf::capture( expect &, error const & ); @@ -152,7 +144,7 @@ namespace boost { namespace leaf { using namespace leaf_detail; typedef typename handler_wrapper::return_type return_type; if( slots_subset::type>::type>...>::have_values(s_,e) ) - return std::make_pair(true, handler_wrapper(std::forward(f))( *leaf::peek::type>::type>(*this,e)... )); + return std::make_pair(true, handler_wrapper(std::forward(f))( *peek::type>::type>(e)... )); else return std::make_pair(false, uhnandled_error::value(e)); } @@ -177,29 +169,66 @@ namespace boost { namespace leaf { { } + ////////////////////////////////////////////// + + template + typename leaf_detail::handler_pack_return_type::return_type handle_error( error const & e, F && ... f ) const noexcept + { + return this->find_handler_( e, std::forward(f)... ).second; + } + + template + P const * peek( error const & e ) const noexcept + { + auto & opt = std::get::value>(s_); + if( opt.has_value() ) + { + auto & x = opt.value(); + if( x.e==e ) + return &x.v; + } + return 0; + } + + ////////////////////////////////////////////// + + template + typename leaf_detail::handler_pack_return_type::return_type handle_error( result const & r, F && ... f ) const noexcept + { + assert(!r); + if( r.which_ == leaf_detail::result_variant::err ) + return this->handle_error(r.err_,f...); + else + { + assert(r.which_==leaf_detail::result_variant::cap); + return r.cap_.handle_error(f...); + } + } + + template + P const * peek( result const & r ) const noexcept + { + assert(!r); + if( r.which_==leaf_detail::result_variant::err ) + return this->template peek

(r.err_); + else + { + assert(r.which_==leaf_detail::result_variant::cap); + return r.cap_.template peek

(); + } + } + + ////////////////////////////////////////////// + + template + P const * peek( std::exception const & ) const noexcept; + + template + void handle_exception( std::exception const &, F && ... ) const; }; //////////////////////////////////////// - template - typename leaf_detail::handler_pack_return_type::return_type handle_error( expect const & exp, error const & e, F && ... f ) noexcept - { - return exp.find_handler_( e, std::forward(f)... ).second; - } - - template - P const * peek( expect const & exp, error const & e ) noexcept - { - auto & opt = std::get::value>(exp.s_); - if( opt.has_value() ) - { - auto & x = opt.value(); - if( x.e==e ) - return &x.v; - } - return 0; - } - template typename leaf_detail::dependent_type>::error_capture capture( expect & exp, error const & e ) { diff --git a/include/boost/leaf/result.hpp b/include/boost/leaf/result.hpp index a84af36..27c75b8 100644 --- a/include/boost/leaf/result.hpp +++ b/include/boost/leaf/result.hpp @@ -32,15 +32,6 @@ namespace boost { namespace leaf { }; } - template - typename leaf_detail::handler_pack_return_type::return_type handle_error( expect const &, result const &, F && ... ) noexcept; - - template - P const * peek( expect const &, result const & ) noexcept; - - template - void diagnostic_output( std::ostream &, result const & ); - template result capture( expect &, result const & ); @@ -49,21 +40,15 @@ namespace boost { namespace leaf { template class result { - template - friend typename leaf_detail::handler_pack_return_type::return_type leaf::handle_error( expect const &, result const &, F && ... ) noexcept; - - template - friend P const * leaf::peek( expect const &, result const & ) noexcept; - - template - friend void leaf::diagnostic_output( std::ostream &, result const & ); - - template - friend result leaf::capture( expect &, result const & ); + template + friend class leaf::expect; template friend class result; + template + friend result leaf::capture( expect &, result const & ); + union { T value_; @@ -255,6 +240,18 @@ namespace boost { namespace leaf { return err_.propagate(std::forward(e)...); } } + + void diagnostic_output( std::ostream & os ) const + { + assert(!(*this)); + if( which_==leaf_detail::result_variant::err ) + return err_.diagnostic_output(os); + else + { + assert(which_==leaf_detail::result_variant::cap); + return cap_.diagnostic_output(os); + } + } }; //////////////////////////////////////// @@ -263,14 +260,8 @@ namespace boost { namespace leaf { class result: result { - template - friend typename leaf_detail::handler_pack_return_type::return_type leaf::handle_error( expect const &, result const &, F && ... ) noexcept; - - template - friend P const * leaf::peek( expect const &, result const & ) noexcept; - - template - friend void leaf::diagnostic_output( std::ostream &, result const & ); + template + friend class leaf::expect; template friend result leaf::capture( expect &, result const & ); @@ -310,36 +301,11 @@ namespace boost { namespace leaf { using base::operator bool; using base::error; + using base::diagnostic_output; }; //////////////////////////////////////// - template - typename leaf_detail::handler_pack_return_type::return_type handle_error( expect const & exp, result const & r, F && ... f ) noexcept - { - assert(!r); - if( r.which_ == leaf_detail::result_variant::err ) - return handle_error(exp,r.err_,f...); - else - { - assert(r.which_==leaf_detail::result_variant::cap); - return handle_error(r.cap_,f...); - } - } - - template - P const * peek( expect const & exp, result const & r ) noexcept - { - assert(!r); - if( r.which_==leaf_detail::result_variant::err ) - return peek

(exp,r.err_); - else - { - assert(r.which_==leaf_detail::result_variant::cap); - return peek

(r.cap_); - } - } - template result capture( expect & exp, result const & r ) { diff --git a/test/basic_test.cpp b/test/basic_test.cpp index 0d5dfca..013c6e5 100644 --- a/test/basic_test.cpp +++ b/test/basic_test.cpp @@ -40,63 +40,63 @@ int main() leaf::expect,info<2>,info<4>> exp0; leaf::error e0 = f4(); { - info<1> const * p = leaf::peek>(exp0,e0); + info<1> const * p = exp0.peek>(e0); BOOST_TEST(p && p->value==1); } { - info<2> const * p = leaf::peek>(exp0,e0); + info<2> const * p = exp0.peek>(e0); BOOST_TEST(p && p->value==2); } - BOOST_TEST(!leaf::peek>(exp0,e0)); + BOOST_TEST(!exp0.peek>(e0)); leaf::expect,info<2>,info<4>> exp; leaf::error e1 = f4(); { - info<1> const * p = leaf::peek>(exp0,e0); + info<1> const * p = exp0.peek>(e0); BOOST_TEST(p && p->value==1); } { - info<2> const * p = leaf::peek>(exp0,e0); + info<2> const * p = exp0.peek>(e0); BOOST_TEST(p && p->value==2); } - BOOST_TEST(!leaf::peek>(exp0,e0)); - BOOST_TEST(!leaf::peek>(exp,e0)); - BOOST_TEST(!leaf::peek>(exp,e0)); - BOOST_TEST(!leaf::peek>(exp,e0)); + BOOST_TEST(!exp0.peek>(e0)); + BOOST_TEST(!exp.peek>(e0)); + BOOST_TEST(!exp.peek>(e0)); + BOOST_TEST(!exp.peek>(e0)); { - info<1> const * p = leaf::peek>(exp,e1); + info<1> const * p = exp.peek>(e1); BOOST_TEST(p && p->value==1); } { - info<2> const * p = leaf::peek>(exp,e1); + info<2> const * p = exp.peek>(e1); BOOST_TEST(p && p->value==2); } - BOOST_TEST(!leaf::peek>(exp,e1)); - BOOST_TEST( !handle_error( exp, e1, [ ](info<1>,info<2>,info<4>)->void { } ) ); + BOOST_TEST(!exp.peek>(e1)); + BOOST_TEST( !exp.handle_error( e1, [ ](info<1>,info<2>,info<4>)->void { } ) ); leaf::error e2 = f4(); { - info<1> const * p = leaf::peek>(exp,e2); + info<1> const * p = exp.peek>(e2); BOOST_TEST(p && p->value==1); } { - info<2> const * p = leaf::peek>(exp,e2); + info<2> const * p = exp.peek>(e2); BOOST_TEST(p && p->value==2); } - BOOST_TEST(!leaf::peek>(exp,e2)); + BOOST_TEST(!exp.peek>(e2)); { int c1=0, c2=0, c3=0; - bool handled = handle_error( exp, e2, + bool handled = exp.handle_error( e2, [&c1]( info<1>, info<2>, info<4> ) { ++c1; @@ -119,7 +119,7 @@ int main() { int c=0; - bool handled = handle_error( exp0, e0, + bool handled = exp0.handle_error( e0, [&c]( info<2> const & i2, info<1> const & i1 ) { BOOST_TEST(i1.value==1); diff --git a/test/defer_test.1.cpp b/test/defer_test.1.cpp index af57613..ea43e91 100644 --- a/test/defer_test.1.cpp +++ b/test/defer_test.1.cpp @@ -39,7 +39,7 @@ int main() { leaf::expect exp; int c=0; - bool handled = handle_error( exp, f(), + bool handled = exp.handle_error( f(), [&c]( info const & i42 ) { BOOST_TEST(i42.value==42); diff --git a/test/defer_test.2.cpp b/test/defer_test.2.cpp index deac3a2..838ed1b 100644 --- a/test/defer_test.2.cpp +++ b/test/defer_test.2.cpp @@ -37,9 +37,9 @@ int main() { leaf::expect,info<1>,info<2>,info<3>,info<4>> exp; leaf::error e = f2(); - BOOST_TEST(!leaf::peek>(exp,e)); + BOOST_TEST(!exp.peek>(e)); int c=0; - bool handled = handle_error( exp, e, + bool handled = exp.handle_error( e, [&c]( info<1> const & i1, info<2> const & i2, info<4> const & i4 ) { BOOST_TEST(i1.value==1); diff --git a/test/defer_test.3.cpp b/test/defer_test.3.cpp index d61bece..9cc2b0e 100644 --- a/test/defer_test.3.cpp +++ b/test/defer_test.3.cpp @@ -36,7 +36,7 @@ int main() leaf::expect exp; leaf::result r = f(); int c=0; - BOOST_TEST( handle_error( exp, r, + BOOST_TEST( exp.handle_error( r, [&c]( info const & x ) { BOOST_TEST(x.value==2); diff --git a/test/defer_test.4.cpp b/test/defer_test.4.cpp index 6296563..b3d3a36 100644 --- a/test/defer_test.4.cpp +++ b/test/defer_test.4.cpp @@ -42,7 +42,7 @@ int main() catch( my_error & e ) { int c=0; - handle_exception( exp, e, + exp.handle_exception( e, [&c]( info const & x ) { BOOST_TEST(x.value==2); diff --git a/test/defer_test.5.cpp b/test/defer_test.5.cpp index 6ccd6b2..9450893 100644 --- a/test/defer_test.5.cpp +++ b/test/defer_test.5.cpp @@ -39,7 +39,7 @@ int main() leaf::expect,info<1>,info<2>,info<3>> exp; leaf::error e = f2(); int c=0; - bool handled = handle_error( exp, e, + bool handled = exp.handle_error( e, [&c]( info<0> const & i0, info<1> const & i1, info<2> const & i2, info<3> const & i3 ) { BOOST_TEST(i0.value==0); diff --git a/test/defer_test.6.cpp b/test/defer_test.6.cpp index 943324a..331ce64 100644 --- a/test/defer_test.6.cpp +++ b/test/defer_test.6.cpp @@ -32,7 +32,7 @@ int main() leaf::expect exp; leaf::error e = f1(); int c=0; - bool handled = handle_error( exp, e, + bool handled = exp.handle_error( e, [&c]( info const & i0 ) { BOOST_TEST(i0.value==0); diff --git a/test/defer_test.7.cpp b/test/defer_test.7.cpp index 0093710..b399ef0 100644 --- a/test/defer_test.7.cpp +++ b/test/defer_test.7.cpp @@ -42,7 +42,7 @@ int main() catch( my_error & e ) { int c=0; - handle_exception( exp, e, + exp.handle_exception( e, [&c]( info const & x ) { BOOST_TEST(x.value==2); diff --git a/test/defer_test.8.cpp b/test/defer_test.8.cpp index a7e1fa5..4aa7a67 100644 --- a/test/defer_test.8.cpp +++ b/test/defer_test.8.cpp @@ -31,7 +31,7 @@ int main() leaf::expect exp; leaf::error e = f1(); int c=0; - bool handled = handle_error( exp, e, + bool handled = exp.handle_error( e, [&c]( leaf::e_unexpected const & unx, leaf::e_unexpected_diagnostic_output const & unxdo ) { BOOST_TEST(unx.count==1); diff --git a/test/diagnostic_output_test.cpp b/test/diagnostic_output_test.cpp index e697d74..3a2786e 100644 --- a/test/diagnostic_output_test.cpp +++ b/test/diagnostic_output_test.cpp @@ -110,7 +110,7 @@ int main() BOOST_TEST(s.find("Detected 2 attempts to communicate unexpected error objects, the first one of type ")!=s.npos); BOOST_TEST(s.find("unexpected_test<2>")!=s.npos); std::cout << s; - handle_exception( exp, e, [ ]{ } ); + exp.handle_exception( e, [ ]{ } ); } } BOOST_TEST(leaf::leaf_detail::tl_unexpected_enabled_counter()==0); diff --git a/test/error_capture_test.1.cpp b/test/error_capture_test.1.cpp index b3b561b..8aa1578 100644 --- a/test/error_capture_test.1.cpp +++ b/test/error_capture_test.1.cpp @@ -29,7 +29,7 @@ int main() { int c=0; - bool r = handle_error( ec, + bool r = ec.handle_error( [&c]( info<1> const & x ) { BOOST_TEST(c==0); @@ -42,7 +42,7 @@ int main() { int c=0; - bool r = handle_error( ec, + bool r = ec.handle_error( [&c]( info<2> const & x ) { BOOST_TEST(c==0); @@ -55,7 +55,7 @@ int main() { int c=0; - int r = handle_error( ec, + int r = ec.handle_error( [&c]( info<1> const & x ) { BOOST_TEST(c==0); @@ -67,7 +67,7 @@ int main() { int c=0; - int r = handle_error( ec, + int r = ec.handle_error( [&c]( info<2> const & x ) { BOOST_TEST(c==0); @@ -79,7 +79,7 @@ int main() { int c=0; - bool r = handle_error( ec, + bool r = ec.handle_error( [&c]( info<1> const & x, info<2> const & ) { BOOST_TEST(c==0); @@ -104,7 +104,7 @@ int main() { int c=0; - bool r = handle_error( ec, + bool r = ec.handle_error( [&c]( info<1> const & x, info<2> const & ) { BOOST_TEST(c==0); @@ -134,7 +134,7 @@ int main() leaf::error e2 = ec.unload(); { int c = 0; - bool r = handle_error( exp, e1, + bool r = exp.handle_error( e1, [&c]( info<1>, info<2>, info<3> ) { BOOST_TEST(c==0); @@ -156,7 +156,7 @@ int main() } { int c = 0; - bool r = handle_error( exp, e2, + bool r = exp.handle_error( e2, [&c]( info<1>, info<2>, info<3> ) { BOOST_TEST(c==0); diff --git a/test/error_capture_test.2.cpp b/test/error_capture_test.2.cpp index 697b18d..705650a 100644 --- a/test/error_capture_test.2.cpp +++ b/test/error_capture_test.2.cpp @@ -50,26 +50,26 @@ int main() { { leaf::error_capture ec1 = make_capture(); - BOOST_TEST( handle_error( ec1, [ ]( info<1>, info<3> ) { } ) ); + BOOST_TEST( ec1.handle_error( [ ]( info<1>, info<3> ) { } ) ); BOOST_TEST(count==2); leaf::error_capture ec2(ec1); BOOST_TEST(count==2); - BOOST_TEST( handle_error( ec1, [ ]( info<1>, info<3> ) { } ) ); - BOOST_TEST( handle_error( ec2, [ ]( info<1>, info<3> ) { } ) ); + BOOST_TEST( ec1.handle_error( [ ]( info<1>, info<3> ) { } ) ); + BOOST_TEST( ec2.handle_error( [ ]( info<1>, info<3> ) { } ) ); leaf::error_capture ec3(std::move(ec2)); BOOST_TEST(count==2); - BOOST_TEST( handle_error( ec1, [ ]( info<1>, info<3> ) { } ) ); - BOOST_TEST( handle_error( ec3, [ ]( info<1>, info<3> ) { } ) ); + BOOST_TEST( ec1.handle_error( [ ]( info<1>, info<3> ) { } ) ); + BOOST_TEST( ec3.handle_error( [ ]( info<1>, info<3> ) { } ) ); leaf::error_capture ec4; ec4 = ec3; BOOST_TEST(count==2); - BOOST_TEST( handle_error( ec1, [ ]( info<1>, info<3> ) { } ) ); - BOOST_TEST( handle_error( ec3, [ ]( info<1>, info<3> ) { } ) ); - BOOST_TEST( handle_error( ec4, [ ]( info<1>, info<3> ) { } ) ); + BOOST_TEST( ec1.handle_error( [ ]( info<1>, info<3> ) { } ) ); + BOOST_TEST( ec3.handle_error( [ ]( info<1>, info<3> ) { } ) ); + BOOST_TEST( ec4.handle_error( [ ]( info<1>, info<3> ) { } ) ); leaf::error_capture ec5; ec5 = std::move(ec4); BOOST_TEST(count==2); - BOOST_TEST( handle_error( ec1, [ ]( info<1>, info<3> ) { } ) ); - BOOST_TEST( handle_error( ec3, [ ]( info<1>, info<3> ) { } ) ); - BOOST_TEST( handle_error( ec5, [ ]( info<1>, info<3> ) { } ) ); + BOOST_TEST( ec1.handle_error( [ ]( info<1>, info<3> ) { } ) ); + BOOST_TEST( ec3.handle_error( [ ]( info<1>, info<3> ) { } ) ); + BOOST_TEST( ec5.handle_error( [ ]( info<1>, info<3> ) { } ) ); } BOOST_TEST(count==0); return boost::report_errors(); diff --git a/test/error_test.cpp b/test/error_test.cpp index c5b9dcf..f3ea124 100644 --- a/test/error_test.cpp +++ b/test/error_test.cpp @@ -37,7 +37,7 @@ leaf::error f3() { leaf::expect,info<3>,unexp<1>> exp; leaf::error e = f2().propagate( info<4>{4} ); - BOOST_TEST(leaf::peek>(exp,e)->value==1); + BOOST_TEST(exp.peek>(e)->value==1); return e; } @@ -46,14 +46,14 @@ leaf::error f4() leaf::expect,info<2>,info<3>,info<4>> exp; { leaf::error e = f3(); - bool handled = handle_error( exp, e, + bool handled = exp.handle_error( e, [ ]( info<1>, info<2>, info<3>, info<4> ){ }, [ ]( info<1>, info<2>, info<4> ) { } ); BOOST_TEST(handled); } leaf::error e = f3(); int c1=0, c2=0; - bool handled = handle_error( exp, e, + bool handled = exp.handle_error( e, [&c1]( info<1>,info<2>,info<3>,info<4> ) { ++c1; @@ -80,9 +80,9 @@ int main() { leaf::expect,info<3>,info<4>> exp; leaf::error e=f4(); - BOOST_TEST(!leaf::peek>(exp,e)); - BOOST_TEST(!leaf::peek>(exp,e)); - BOOST_TEST(!leaf::peek>(exp,e)); + BOOST_TEST(!exp.peek>(e)); + BOOST_TEST(!exp.peek>(e)); + BOOST_TEST(!exp.peek>(e)); BOOST_TEST(leaf::leaf_detail::tl_slot_ptr>()==0); BOOST_TEST(leaf::leaf_detail::tl_slot_ptr>()!=0); BOOST_TEST(leaf::leaf_detail::tl_slot_ptr>()!=0); diff --git a/test/exception_capture_test.cpp b/test/exception_capture_test.cpp index 53c1ab2..d232b1d 100644 --- a/test/exception_capture_test.cpp +++ b/test/exception_capture_test.cpp @@ -64,7 +64,7 @@ void test( int task_count, F && f ) noexcept catch( my_error const & e ) { int c=0; - handle_exception( exp, e, [&f,&c]( info<1> const & x1, info<2> const & x2 ) + exp.handle_exception( e, [&f,&c]( info<1> const & x1, info<2> const & x2 ) { BOOST_TEST(x1.value==f.a); BOOST_TEST(x2.value==f.b); diff --git a/test/exception_test.1.cpp b/test/exception_test.1.cpp index 8938544..7ce7d70 100644 --- a/test/exception_test.1.cpp +++ b/test/exception_test.1.cpp @@ -60,7 +60,7 @@ void f4() catch( my_error const & e ) { int c1=0, c2=0; - handle_exception( exp, e, + exp.handle_exception( e, [&c1]( info<1>, info<2>, info<3>, info<4> ) { ++c1; @@ -90,9 +90,9 @@ void test( std::function const & f ) } catch( my_error const & e ) { - BOOST_TEST(!leaf::peek>(exp,e)); - BOOST_TEST(!leaf::peek>(exp,e)); - BOOST_TEST(!leaf::peek>(exp,e)); + BOOST_TEST(!exp.peek>(e)); + BOOST_TEST(!exp.peek>(e)); + BOOST_TEST(!exp.peek>(e)); BOOST_TEST(leaf::leaf_detail::tl_slot_ptr>()==0); BOOST_TEST(leaf::leaf_detail::tl_slot_ptr>()!=0); BOOST_TEST(leaf::leaf_detail::tl_slot_ptr>()!=0); diff --git a/test/exception_test.2.cpp b/test/exception_test.2.cpp index 7db1403..cfc61a1 100644 --- a/test/exception_test.2.cpp +++ b/test/exception_test.2.cpp @@ -60,7 +60,7 @@ void f4() catch( my_error const & e ) { int c1=0, c2=0; - handle_exception( exp, e, + exp.handle_exception( e, [&c1]( info<1>, info<2>, info<3>, info<4> ) { ++c1; @@ -90,9 +90,9 @@ void test( std::function const & f ) } catch( my_error const & e ) { - BOOST_TEST(!leaf::peek>(exp,e)); - BOOST_TEST(!leaf::peek>(exp,e)); - BOOST_TEST(!leaf::peek>(exp,e)); + BOOST_TEST(!exp.peek>(e)); + BOOST_TEST(!exp.peek>(e)); + BOOST_TEST(!exp.peek>(e)); BOOST_TEST(leaf::leaf_detail::tl_slot_ptr>()==0); BOOST_TEST(leaf::leaf_detail::tl_slot_ptr>()!=0); BOOST_TEST(leaf::leaf_detail::tl_slot_ptr>()!=0); diff --git a/test/expect_fail_test.1.cpp b/test/expect_fail_test.1.cpp index 9c8a913..d90c1e2 100644 --- a/test/expect_fail_test.1.cpp +++ b/test/expect_fail_test.1.cpp @@ -19,7 +19,7 @@ int main() { leaf::expect,info<2>,info<3>> exp; - (void) handle_error( exp, f(), + (void) exp.handle_error( f(), [ ]( info<1>, info<2> ) { return 42; diff --git a/test/expect_fail_test.2.cpp b/test/expect_fail_test.2.cpp index 40b42cb..70555d3 100644 --- a/test/expect_fail_test.2.cpp +++ b/test/expect_fail_test.2.cpp @@ -21,7 +21,7 @@ int main() { leaf::expect,info<2>,info<3>> exp; - (void) handle_error( exp, f(), + (void) exp.handle_error( f(), [ ]( info<1>, info<2> ) { return test { }; diff --git a/test/expect_test.1.cpp b/test/expect_test.1.cpp index 2905a68..a0a56ec 100644 --- a/test/expect_test.1.cpp +++ b/test/expect_test.1.cpp @@ -26,7 +26,7 @@ int main() { leaf::expect exp; int c=0; - BOOST_TEST( !handle_error( exp, f(), + BOOST_TEST( !exp.handle_error( f(), [&c]( info ) { ++c; diff --git a/test/expect_test.2.cpp b/test/expect_test.2.cpp index 61f8515..e80a0fc 100644 --- a/test/expect_test.2.cpp +++ b/test/expect_test.2.cpp @@ -38,7 +38,7 @@ int main() int c=0; try { - handle_exception( exp, e, + exp.handle_exception( e, [&c]( info ) { ++c; diff --git a/test/expect_test.3.cpp b/test/expect_test.3.cpp index 92d1374..a256572 100644 --- a/test/expect_test.3.cpp +++ b/test/expect_test.3.cpp @@ -38,7 +38,7 @@ int main() int c=0; try { - handle_exception( exp, e, + exp.handle_exception( e, [&c]( info ) { ++c; diff --git a/test/expect_test.4.cpp b/test/expect_test.4.cpp index 3184979..da51c41 100644 --- a/test/expect_test.4.cpp +++ b/test/expect_test.4.cpp @@ -23,7 +23,7 @@ int main() MStatus copy = ms; { int c=0; - bool handled = leaf::handle_error( exp, leaf::error(copy), + bool handled = exp.handle_error( leaf::error(copy), [&c]( MStatus ms ) { ++c; @@ -33,7 +33,7 @@ int main() } { int c=0; - bool handled = leaf::handle_error( exp, leaf::error(copy), + bool handled = exp.handle_error( leaf::error(copy), [&c]( MStatus const ms ) { ++c; @@ -43,7 +43,7 @@ int main() } { int c=0; - bool handled = leaf::handle_error( exp, leaf::error(copy), + bool handled = exp.handle_error( leaf::error(copy), [&c]( MStatus const & ms ) { ++c; @@ -56,7 +56,7 @@ int main() MStatus & ref = ms; { int c=0; - bool handled = leaf::handle_error( exp, leaf::error(ref), + bool handled = exp.handle_error( leaf::error(ref), [&c]( MStatus ms ) { ++c; @@ -66,7 +66,7 @@ int main() } { int c=0; - bool handled = leaf::handle_error( exp, leaf::error(ref), + bool handled = exp.handle_error( leaf::error(ref), [&c]( MStatus const ms ) { ++c; @@ -76,7 +76,7 @@ int main() } { int c=0; - bool handled = leaf::handle_error( exp, leaf::error(ref), + bool handled = exp.handle_error( leaf::error(ref), [&c]( MStatus const & ms ) { ++c; @@ -89,7 +89,7 @@ int main() { MStatus const & cref = ms; int c=0; - bool handled = leaf::handle_error( exp, leaf::error(cref), + bool handled = exp.handle_error( leaf::error(cref), [&c]( MStatus ms ) { ++c; @@ -100,7 +100,7 @@ int main() { MStatus const & cref = ms; int c=0; - bool handled = leaf::handle_error( exp, leaf::error(cref), + bool handled = exp.handle_error( leaf::error(cref), [&c]( MStatus const ms ) { ++c; @@ -111,7 +111,7 @@ int main() { MStatus const & cref = ms; int c=0; - bool handled = leaf::handle_error( exp, leaf::error(cref), + bool handled = exp.handle_error( leaf::error(cref), [&c]( MStatus const & ms ) { ++c; diff --git a/test/expect_test.5.cpp b/test/expect_test.5.cpp index 47681a1..263f43a 100644 --- a/test/expect_test.5.cpp +++ b/test/expect_test.5.cpp @@ -22,7 +22,7 @@ int main() { int c=0; - bool r = handle_error( exp, f(), + bool r = exp.handle_error( f(), [&c]( info<1> const & x ) { BOOST_TEST(c==0); @@ -35,7 +35,7 @@ int main() { int c=0; - bool r = handle_error( exp, f(), + bool r = exp.handle_error( f(), [&c]( info<2> const & x ) { BOOST_TEST(c==0); @@ -48,7 +48,7 @@ int main() { int c=0; - int r = handle_error( exp, f(), + int r = exp.handle_error( f(), [&c]( info<1> const & x ) { BOOST_TEST(c==0); @@ -60,7 +60,7 @@ int main() { int c=0; - int r = handle_error( exp, f(), + int r = exp.handle_error( f(), [&c]( info<2> const & x ) { BOOST_TEST(c==0); @@ -72,7 +72,7 @@ int main() { int c=0; - bool r = handle_error( exp, f(), + bool r = exp.handle_error( f(), [&c]( info<1> const & x, info<2> const & ) { BOOST_TEST(c==0); @@ -97,7 +97,7 @@ int main() { int c=0; - bool r = handle_error( exp, f(), + bool r = exp.handle_error( f(), [&c]( info<1> const & x, info<2> const & ) { BOOST_TEST(c==0); diff --git a/test/multiple_errors_test.cpp b/test/multiple_errors_test.cpp index 7e057b6..f7174ec 100644 --- a/test/multiple_errors_test.cpp +++ b/test/multiple_errors_test.cpp @@ -32,7 +32,7 @@ int main() leaf::error e2=f34(); { int e1c1=0, e1c2=0; - bool handled = handle_error( exp, e1, + bool handled = exp.handle_error( e1, [&e1c1]( info<3>, info<4> ) { ++e1c1; @@ -49,7 +49,7 @@ int main() } { int e2c1=0, e2c2=0; - bool handled = handle_error( exp, e2, + bool handled = exp.handle_error( e2, [&e2c1]( info<1>, info<2> ) { ++e2c1; diff --git a/test/preload_test.1.cpp b/test/preload_test.1.cpp index 4c90b00..84a7793 100644 --- a/test/preload_test.1.cpp +++ b/test/preload_test.1.cpp @@ -37,9 +37,9 @@ int main() { leaf::expect,info<1>,info<2>,info<3>,info<4>> exp; leaf::error e = f2(); - BOOST_TEST(!leaf::peek>(exp,e)); + BOOST_TEST(!exp.peek>(e)); int c=0; - bool handled = handle_error( exp, e, + bool handled = exp.handle_error( e, [&c]( info<0> const & i0, info<1> const & i1, info<2> const & i2, info<4> const & i4 ) { BOOST_TEST(i0.value==0); diff --git a/test/preload_test.2.cpp b/test/preload_test.2.cpp index 9e43ea7..f6b8bf5 100644 --- a/test/preload_test.2.cpp +++ b/test/preload_test.2.cpp @@ -37,7 +37,7 @@ main() leaf::expect exp; leaf::result r = f(); int c=0; - bool handled = handle_error( exp, r, + bool handled = exp.handle_error( r, [&c]( info const & x ) { BOOST_TEST(x.value==2); diff --git a/test/preload_test.3.cpp b/test/preload_test.3.cpp index 04a9c16..0f0c978 100644 --- a/test/preload_test.3.cpp +++ b/test/preload_test.3.cpp @@ -42,7 +42,7 @@ int main() catch( my_error & e ) { int c=0; - handle_exception( exp, e, + exp.handle_exception( e, [&c]( info const & x ) { BOOST_TEST(x.value==2); diff --git a/test/preload_test.4.cpp b/test/preload_test.4.cpp index d2939f3..9f07a7c 100644 --- a/test/preload_test.4.cpp +++ b/test/preload_test.4.cpp @@ -42,7 +42,7 @@ int main() catch( my_error & e ) { int c=0; - handle_exception( exp, e, + exp.handle_exception( e, [&c]( info const & x ) { BOOST_TEST(x.value==2); diff --git a/test/preload_test.5.cpp b/test/preload_test.5.cpp index a9fa9d1..9e6219c 100644 --- a/test/preload_test.5.cpp +++ b/test/preload_test.5.cpp @@ -39,7 +39,7 @@ int main() leaf::expect,info<1>,info<2>,info<3>> exp; leaf::error e = f2(); int c=0; - bool handled = handle_error( exp, e, + bool handled = exp.handle_error( e, [&c]( info<0> const & i0, info<1> const & i1, info<2> const & i2, info<3> const & i3 ) { BOOST_TEST(i0.value==0); diff --git a/test/preload_test.6.cpp b/test/preload_test.6.cpp index e935b60..ffceb60 100644 --- a/test/preload_test.6.cpp +++ b/test/preload_test.6.cpp @@ -32,7 +32,7 @@ int main() leaf::expect exp; leaf::error e = f1(); int c=0; - bool handled = handle_error( exp, e, + bool handled = exp.handle_error( e, [&c]( info const & i0 ) { BOOST_TEST(i0.value==0); diff --git a/test/preload_test.7.cpp b/test/preload_test.7.cpp index 13cc6f5..71585f5 100644 --- a/test/preload_test.7.cpp +++ b/test/preload_test.7.cpp @@ -31,7 +31,7 @@ int main() leaf::expect exp; leaf::error e = f1(); int c=0; - bool handled = handle_error( exp, e, + bool handled = exp.handle_error( e, [&c]( leaf::e_unexpected const & unx, leaf::e_unexpected_diagnostic_output const & unxdo ) { BOOST_TEST(unx.count==1); diff --git a/test/result_capture_test.cpp b/test/result_capture_test.cpp index 6803361..4e7c893 100644 --- a/test/result_capture_test.cpp +++ b/test/result_capture_test.cpp @@ -65,7 +65,7 @@ int main() else { int c=0; - bool handled = handle_error( exp, r, [&f,&c]( info<1> const & x1, info<2> const & x2 ) + bool handled = exp.handle_error( r, [&f,&c]( info<1> const & x1, info<2> const & x2 ) { BOOST_TEST(x1.value==f.a); BOOST_TEST(x2.value==f.b); diff --git a/test/result_test.1.cpp b/test/result_test.1.cpp index 0273b7d..76066e2 100644 --- a/test/result_test.1.cpp +++ b/test/result_test.1.cpp @@ -53,7 +53,7 @@ leaf::result f4( bool success ) else { int c1=0, c2=0; - bool handled = handle_error( exp, r, + bool handled = exp.handle_error( r, [&c1]( info<1>, info<2>, info<3>, info<4> ) { ++c1; @@ -79,9 +79,9 @@ int main() leaf::result r=f4(false); BOOST_TEST(!r); leaf::error e = r.error(); - BOOST_TEST(!leaf::peek>(exp,e)); - BOOST_TEST(!leaf::peek>(exp,e)); - BOOST_TEST(!leaf::peek>(exp,e)); + BOOST_TEST(!exp.peek>(e)); + BOOST_TEST(!exp.peek>(e)); + BOOST_TEST(!exp.peek>(e)); BOOST_TEST(leaf::leaf_detail::tl_slot_ptr>()==0); BOOST_TEST(leaf::leaf_detail::tl_slot_ptr>()!=0); BOOST_TEST(leaf::leaf_detail::tl_slot_ptr>()!=0); diff --git a/test/result_test.2.cpp b/test/result_test.2.cpp index cb5e64f..2ef6566 100644 --- a/test/result_test.2.cpp +++ b/test/result_test.2.cpp @@ -402,7 +402,7 @@ int main() BOOST_TEST(val::count==0); leaf::result r2 = r1; BOOST_TEST(!r2); - BOOST_TEST(handle_error(exp,r2,[ ]{ })); + BOOST_TEST(exp.handle_error(r2,[ ]{ })); BOOST_TEST(err::count==1); BOOST_TEST(val::count==0); } @@ -417,7 +417,7 @@ int main() BOOST_TEST(val::count==0); leaf::result r2 = r1; BOOST_TEST(!r2); - BOOST_TEST(handle_error(exp,r2,[ ]{ })); + BOOST_TEST(exp.handle_error(r2,[ ]{ })); BOOST_TEST(err::count==1); BOOST_TEST(val::count==0); } @@ -432,7 +432,7 @@ int main() BOOST_TEST(val::count==0); leaf::result r2 = std::move(r1); BOOST_TEST(!r2); - BOOST_TEST(handle_error(exp,r2,[ ]{ })); + BOOST_TEST(exp.handle_error(r2,[ ]{ })); BOOST_TEST(err::count==1); BOOST_TEST(val::count==0); } @@ -447,7 +447,7 @@ int main() BOOST_TEST(val::count==0); leaf::result r2 = std::move(r1); BOOST_TEST(!r2); - BOOST_TEST(handle_error(exp,r2,[ ]{ })); + BOOST_TEST(exp.handle_error(r2,[ ]{ })); BOOST_TEST(err::count==1); BOOST_TEST(val::count==0); } @@ -462,7 +462,7 @@ int main() BOOST_TEST(val::count==0); leaf::result r2; r2=r1; BOOST_TEST(!r2); - BOOST_TEST(handle_error(exp,r2,[ ]{ })); + BOOST_TEST(exp.handle_error(r2,[ ]{ })); BOOST_TEST(err::count==1); BOOST_TEST(val::count==0); } @@ -477,7 +477,7 @@ int main() BOOST_TEST(val::count==0); leaf::result r2; r2=r1; BOOST_TEST(!r2); - BOOST_TEST(handle_error(exp,r2,[ ]{ })); + BOOST_TEST(exp.handle_error(r2,[ ]{ })); BOOST_TEST(err::count==1); BOOST_TEST(val::count==0); } @@ -492,7 +492,7 @@ int main() BOOST_TEST(val::count==0); leaf::result r2; r2=std::move(r1); BOOST_TEST(!r2); - BOOST_TEST(handle_error(exp,r2,[ ]{ })); + BOOST_TEST(exp.handle_error(r2,[ ]{ })); BOOST_TEST(err::count==1); BOOST_TEST(val::count==0); } @@ -507,7 +507,7 @@ int main() BOOST_TEST(val::count==0); leaf::result r2; r2=std::move(r1); BOOST_TEST(!r2); - BOOST_TEST(handle_error(exp,r2,[ ]{ })); + BOOST_TEST(exp.handle_error(r2,[ ]{ })); BOOST_TEST(err::count==1); BOOST_TEST(val::count==0); } @@ -522,7 +522,7 @@ int main() BOOST_TEST(val::count==0); leaf::result r2 = r1; BOOST_TEST(!r2); - BOOST_TEST(handle_error(exp,r2,[ ]{ })); + BOOST_TEST(exp.handle_error(r2,[ ]{ })); BOOST_TEST(err::count==1); BOOST_TEST(val::count==0); } @@ -537,7 +537,7 @@ int main() BOOST_TEST(val::count==0); leaf::result r2 = r1; BOOST_TEST(!r2); - BOOST_TEST(handle_error(exp,r2,[ ]{ })); + BOOST_TEST(exp.handle_error(r2,[ ]{ })); BOOST_TEST(err::count==1); BOOST_TEST(val::count==0); } @@ -552,7 +552,7 @@ int main() BOOST_TEST(val::count==0); leaf::result r2 = std::move(r1); BOOST_TEST(!r2); - BOOST_TEST(handle_error(exp,r2,[ ]{ })); + BOOST_TEST(exp.handle_error(r2,[ ]{ })); BOOST_TEST(err::count==1); BOOST_TEST(val::count==0); } @@ -567,7 +567,7 @@ int main() BOOST_TEST(val::count==0); leaf::result r2 = std::move(r1); BOOST_TEST(!r2); - BOOST_TEST(handle_error(exp,r2,[ ]{ })); + BOOST_TEST(exp.handle_error(r2,[ ]{ })); BOOST_TEST(err::count==1); BOOST_TEST(val::count==0); } @@ -582,7 +582,7 @@ int main() BOOST_TEST(val::count==0); leaf::result r2; r2=r1; BOOST_TEST(!r2); - BOOST_TEST(handle_error(exp,r2,[ ]{ })); + BOOST_TEST(exp.handle_error(r2,[ ]{ })); BOOST_TEST(err::count==1); BOOST_TEST(val::count==0); } @@ -597,7 +597,7 @@ int main() BOOST_TEST(val::count==0); leaf::result r2; r2=r1; BOOST_TEST(!r2); - BOOST_TEST(handle_error(exp,r2,[ ]{ })); + BOOST_TEST(exp.handle_error(r2,[ ]{ })); BOOST_TEST(err::count==1); BOOST_TEST(val::count==0); } @@ -612,7 +612,7 @@ int main() BOOST_TEST(val::count==0); leaf::result r2; r2=std::move(r1); BOOST_TEST(!r2); - BOOST_TEST(handle_error(exp,r2,[ ]{ })); + BOOST_TEST(exp.handle_error(r2,[ ]{ })); BOOST_TEST(err::count==1); BOOST_TEST(val::count==0); } @@ -627,7 +627,7 @@ int main() BOOST_TEST(val::count==0); leaf::result r2; r2=std::move(r1); BOOST_TEST(!r2); - BOOST_TEST(handle_error(exp,r2,[ ]{ })); + BOOST_TEST(exp.handle_error(r2,[ ]{ })); BOOST_TEST(err::count==1); BOOST_TEST(val::count==0); } diff --git a/test/result_test.3.cpp b/test/result_test.3.cpp index 718f44a..25d2545 100644 --- a/test/result_test.3.cpp +++ b/test/result_test.3.cpp @@ -54,6 +54,6 @@ int main() leaf::expect exp; leaf::result r2 = r0.error( e_err2{ } ); BOOST_TEST(err::count==2); - BOOST_TEST(handle_error(exp,r2,[ ](e_err1,e_err2){ })); + BOOST_TEST(exp.handle_error(r2,[ ](e_err1,e_err2){ })); return boost::report_errors(); } diff --git a/test/result_test.4.cpp b/test/result_test.4.cpp index 051e200..76af89f 100644 --- a/test/result_test.4.cpp +++ b/test/result_test.4.cpp @@ -14,7 +14,7 @@ namespace leaf = boost::leaf; template void check( Expect & exp, leaf::bad_result const & e ) { - handle_exception( exp, e, + exp.handle_exception( e, [ ]( leaf::e_source_location const & x ) { BOOST_TEST(strstr(x.file,"result.hpp")!=0); diff --git a/test/result_test.5.cpp b/test/result_test.5.cpp index 577d539..1eefb84 100644 --- a/test/result_test.5.cpp +++ b/test/result_test.5.cpp @@ -23,7 +23,7 @@ int main() { int c=0; - bool r = handle_error( exp, f(), + bool r = exp.handle_error( f(), [&c]( info<1> const & x ) { BOOST_TEST(c==0); @@ -36,7 +36,7 @@ int main() { int c=0; - bool r = handle_error( exp, f(), + bool r = exp.handle_error( f(), [&c]( info<2> const & x ) { BOOST_TEST(c==0); @@ -49,7 +49,7 @@ int main() { int c=0; - int r = handle_error( exp, f(), + int r = exp.handle_error( f(), [&c]( info<1> const & x ) { BOOST_TEST(c==0); @@ -61,7 +61,7 @@ int main() { int c=0; - int r = handle_error( exp, f(), + int r = exp.handle_error( f(), [&c]( info<2> const & x ) { BOOST_TEST(c==0); @@ -73,7 +73,7 @@ int main() { int c=0; - bool r = handle_error( exp, f(), + bool r = exp.handle_error( f(), [&c]( info<1> const & x, info<2> const & ) { BOOST_TEST(c==0); @@ -98,7 +98,7 @@ int main() { int c=0; - bool r = handle_error( exp, f(), + bool r = exp.handle_error( f(), [&c]( info<1> const & x, info<2> const & ) { BOOST_TEST(c==0); @@ -124,7 +124,7 @@ int main() { int c=0; - leaf::result r = handle_error( exp, f(), + leaf::result r = exp.handle_error( f(), [&c]( info<1> const & x, info<3> const & ) -> leaf::result { BOOST_TEST(c==0); @@ -139,7 +139,7 @@ int main() int c=0; leaf::result r1 = f(); leaf::expect> exp1; - leaf::result r2 = handle_error( exp, r1, + leaf::result r2 = exp.handle_error( r1, [&c]( info<1> const & x, info<3> const & ) -> leaf::result { BOOST_TEST(c==0); @@ -148,7 +148,7 @@ int main() } ); BOOST_TEST(c==1); c = 0; - bool b = handle_error( exp1, r2, + bool b = exp1.handle_error( r2, [&c]( info<42> const & x ) { BOOST_TEST(c==0); @@ -162,7 +162,7 @@ int main() { int c=0; leaf::result r1 = f(); - leaf::result r2 = handle_error( exp, r1, + leaf::result r2 = exp.handle_error( r1, [&c]( info<2> const & ) -> leaf::result { BOOST_TEST(c==0); @@ -170,7 +170,7 @@ int main() return 42; } ); BOOST_TEST(c==0); - bool b = handle_error( exp, r2, + bool b = exp.handle_error( r2, [&c]( info<1> const & x, info<3> const & y ) { BOOST_TEST(c==0); diff --git a/test/result_test.6.cpp b/test/result_test.6.cpp index 22bcd40..89490b8 100644 --- a/test/result_test.6.cpp +++ b/test/result_test.6.cpp @@ -43,7 +43,7 @@ leaf::result handle_some_errors( int what_to_do ) if( leaf::result r = compute_answer(what_to_do) ) return r; else - return handle_error( exp, r, + return exp.handle_error( r, [&r]( error_code ec ) -> leaf::result { if( ec==error_code::error1 ) @@ -59,7 +59,7 @@ leaf::result handle_some_errors_float( int what_to_do ) if( leaf::result r = compute_answer(what_to_do) ) return r; else - return handle_error( exp, r, + return exp.handle_error( r, [&r]( error_code ec ) -> leaf::result { if( ec==error_code::error2 ) @@ -75,7 +75,7 @@ leaf::result handle_some_errors_void( int what_to_do ) if( leaf::result r = compute_answer(what_to_do) ) return { }; else - return handle_error( exp, r, + return exp.handle_error( r, [&r]( error_code ec ) -> leaf::result { if( ec==error_code::error3 ) @@ -97,7 +97,7 @@ int main() leaf::result r = handle_some_errors(2); BOOST_TEST(!r); int c=0; - BOOST_TEST( handle_error( exp, r, + BOOST_TEST( exp.handle_error( r, [&c]( error_code ec ) { BOOST_TEST(ec==error_code::error2); @@ -109,7 +109,7 @@ int main() leaf::result r = handle_some_errors(3); BOOST_TEST(!r); int c=0; - BOOST_TEST( handle_error( exp, r, + BOOST_TEST( exp.handle_error( r, [&c]( error_code ec ) { BOOST_TEST(ec==error_code::error3); @@ -125,7 +125,7 @@ int main() leaf::result r = handle_some_errors_float(1); BOOST_TEST(!r); int c=0; - BOOST_TEST( handle_error( exp, r, + BOOST_TEST( exp.handle_error( r, [&c]( error_code ec ) { BOOST_TEST(ec==error_code::error1); @@ -138,7 +138,7 @@ int main() leaf::result r = handle_some_errors_float(3); BOOST_TEST(!r); int c=0; - BOOST_TEST( handle_error( exp, r, + BOOST_TEST( exp.handle_error( r, [&c]( error_code ec ) { BOOST_TEST(ec==error_code::error3); @@ -154,7 +154,7 @@ int main() leaf::result r = handle_some_errors_void(1); BOOST_TEST(!r); int c=0; - BOOST_TEST( handle_error( exp, r, + BOOST_TEST( exp.handle_error( r, [&c]( error_code ec ) { BOOST_TEST(ec==error_code::error1); @@ -166,7 +166,7 @@ int main() leaf::result r = handle_some_errors_void(2); BOOST_TEST(!r); int c=0; - BOOST_TEST( handle_error( exp, r, + BOOST_TEST( exp.handle_error( r, [&c]( error_code ec ) { BOOST_TEST(ec==error_code::error2); diff --git a/test/result_void_capture_test.cpp b/test/result_void_capture_test.cpp index 9aa6bcd..43b2807 100644 --- a/test/result_void_capture_test.cpp +++ b/test/result_void_capture_test.cpp @@ -64,7 +64,7 @@ int main() else { int c=0; - bool handled = handle_error( exp, r, [&f,&c]( info<1> const & x1, info<2> const & x2 ) + bool handled = exp.handle_error( r, [&f,&c]( info<1> const & x1, info<2> const & x2 ) { BOOST_TEST(x1.value==f.a); BOOST_TEST(x2.value==f.b);