tests/p2497.cpp
raw| 1 | #include "fast_float/fast_float.h" |
| 2 | |
| 3 | #include <iostream> |
| 4 | #include <string> |
| 5 | |
| 6 | int main() { |
| 7 | std::string input = "3.1416 xyz "; |
| 8 | double result; |
| 9 | if (auto answer = fast_float::from_chars( |
| 10 | input.data(), input.data() + input.size(), result)) { |
| 11 | std::cout << "parsed the number " << result << std::endl; |
| 12 | return EXIT_SUCCESS; |
| 13 | } |
| 14 | std::cerr << "failed to parse " << result << std::endl; |
| 15 | return EXIT_FAILURE; |
| 16 | } |