This function handles ConversionErrc::TooLong errors, forwards any other error to the caller.
| 46 | // This function handles ConversionErrc::TooLong errors, forwards any other |
| 47 | // error to the caller. |
| 48 | leaf::result<void> print_half(const std::string& text) |
| 49 | { |
| 50 | return leaf::try_handle_some( |
| 51 | [&]() -> leaf::result<void> |
| 52 | { |
| 53 | BOOST_LEAF_AUTO(r,convert(text)); |
| 54 | std::cout << r / 2 << std::endl; |
| 55 | return { }; |
| 56 | }, |
| 57 | [&]( leaf::match<ConversionErrc, ConversionErrc::TooLong> ) -> leaf::result<void> |
| 58 | { |
| 59 | BOOST_LEAF_AUTO(i, BigInt::fromString(text)); |
| 60 | std::cout << i.half() << std::endl; |
| 61 | return { }; |
| 62 | } ); |
| 63 | } |
| 64 | |
| 65 | int main( int argc, char const * argv[] ) |
| 66 | { |
no test coverage detected