| 39 | |
| 40 | template <class R> |
| 41 | void test() |
| 42 | { |
| 43 | #if __cplusplus >= 201703L |
| 44 | { |
| 45 | int r = leaf::try_handle_all( |
| 46 | []() -> R |
| 47 | { |
| 48 | return make_error_code(errc_a::a0); |
| 49 | }, |
| 50 | []( leaf::match<std::error_code, leaf::category<errc_a>, leaf::category<errc_b>> code ) |
| 51 | { |
| 52 | std::error_code const & ec = code.matched; |
| 53 | BOOST_TEST_EQ(&ec.category(), &cat_errc_a()); |
| 54 | BOOST_TEST_EQ(ec, errc_a::a0); |
| 55 | return 42; |
| 56 | }, |
| 57 | [] |
| 58 | { |
| 59 | return -42; |
| 60 | } ); |
| 61 | BOOST_TEST_EQ(r, 42); |
| 62 | } |
| 63 | { |
| 64 | int r = leaf::try_handle_all( |
| 65 | []() -> R |
| 66 | { |
| 67 | return make_error_code(errc_b::b0); |
| 68 | }, |
| 69 | []( leaf::match<std::error_code, leaf::category<errc_a>, leaf::category<errc_b>> code ) |
| 70 | { |
| 71 | std::error_code const & ec = code.matched; |
| 72 | BOOST_TEST_EQ(&ec.category(), &cat_errc_b()); |
| 73 | BOOST_TEST_EQ(ec, errc_b::b0); |
| 74 | return 42; |
| 75 | }, |
| 76 | [] |
| 77 | { |
| 78 | return -42; |
| 79 | } ); |
| 80 | BOOST_TEST_EQ(r, 42); |
| 81 | } |
| 82 | { |
| 83 | int r = leaf::try_handle_all( |
| 84 | []() -> R |
| 85 | { |
| 86 | return make_error_code(errc_b::b0); |
| 87 | }, |
| 88 | []( leaf::match<std::error_code, leaf::category<errc_a>, errc_b::b0> code ) |
| 89 | { |
| 90 | std::error_code const & ec = code.matched; |
| 91 | BOOST_TEST_EQ(&ec.category(), &cat_errc_b()); |
| 92 | BOOST_TEST_EQ(ec, errc_b::b0); |
| 93 | return 42; |
| 94 | }, |
| 95 | [] |
| 96 | { |
| 97 | return -42; |
| 98 | } ); |
nothing calls this directly
no test coverage detected