| 31 | } |
| 32 | |
| 33 | int main() |
| 34 | { |
| 35 | { |
| 36 | int r = leaf::try_handle_all( |
| 37 | []() -> leaf::result<int> |
| 38 | { |
| 39 | leaf::result<void> r1 = f12(); |
| 40 | (void) r1; |
| 41 | leaf::result<void> r2 = f23(); |
| 42 | return r2.error(); |
| 43 | }, |
| 44 | []( info<1> ) |
| 45 | { |
| 46 | return 1; |
| 47 | }, |
| 48 | []( info<2> const & x, info<3> const & y ) |
| 49 | { |
| 50 | BOOST_TEST_EQ(x.value, 2); |
| 51 | BOOST_TEST_EQ(y.value, 3); |
| 52 | return 2; |
| 53 | }, |
| 54 | [] |
| 55 | { |
| 56 | return 3; |
| 57 | } ); |
| 58 | BOOST_TEST_EQ(r, 2); |
| 59 | } |
| 60 | |
| 61 | #ifndef BOOST_LEAF_NO_EXCEPTIONS |
| 62 | { |
| 63 | int r = leaf::try_catch( |
| 64 | []() -> int |
| 65 | { |
| 66 | try |
| 67 | { |
| 68 | leaf::throw_exception(info<4>{4}); |
| 69 | } |
| 70 | catch(...) |
| 71 | { |
| 72 | } |
| 73 | throw std::exception{}; |
| 74 | }, |
| 75 | []( std::exception const &, info<4> ) |
| 76 | { |
| 77 | return 1; |
| 78 | }, |
| 79 | []( std::exception const & ) |
| 80 | { |
| 81 | return 2; |
| 82 | } ); |
| 83 | BOOST_TEST_EQ(r, 2); |
| 84 | } |
| 85 | { |
| 86 | int r = leaf::try_catch( |
| 87 | []() -> int |
| 88 | { |
| 89 | try |
| 90 | { |
nothing calls this directly
no test coverage detected