| 20 | } |
| 21 | |
| 22 | int main() |
| 23 | { |
| 24 | auto process = [](std::string_view str) { |
| 25 | std::print("str: {:?}, ", str); |
| 26 | parse_number(str) |
| 27 | .transform([](double val) { |
| 28 | std::println("value: {}", val); |
| 29 | return val; |
| 30 | }) |
| 31 | .transform_error([](std::errc err) { |
| 32 | if (err == std::errc::invalid_argument) |
| 33 | std::println("error: invalid input"); |
| 34 | else if (err == std::errc::result_out_of_range) |
| 35 | std::println("error: overflow"); |
| 36 | return err; |
| 37 | }); |
| 38 | }; |
| 39 | |
| 40 | for (auto src : { "42", "42abc", "meow", "inf" }) |
| 41 | process(src); |
| 42 | return 0; |
| 43 | } |
nothing calls this directly
no test coverage detected