MCPcopy Create free account
hub / github.com/boostorg/leaf / print_half

Function print_half

example/print_half.cpp:48–63  ·  view source on GitHub ↗

This function handles ConversionErrc::TooLong errors, forwards any other error to the caller.

Source from the content-addressed store, hash-verified

46// This function handles ConversionErrc::TooLong errors, forwards any other
47// error to the caller.
48leaf::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
65int main( int argc, char const * argv[] )
66{

Callers 1

mainFunction · 0.85

Calls 3

try_handle_someFunction · 0.85
convertFunction · 0.85
halfMethod · 0.80

Tested by

no test coverage detected