| 1 |
|
| 2 |
#include "fast_float/fast_float.h" |
| 3 |
#include <iostream> |
| 4 |
#include <string> |
| 5 |
#include <system_error> |
| 6 |
|
| 7 |
int main() { |
| 8 |
std::string const input = "3,1416 xyz "; |
| 9 |
double result; |
| 10 |
fast_float::parse_options options{fast_float::chars_format::general, ','}; |
| 11 |
auto answer = fast_float::from_chars_advanced( |
| 12 |
input.data(), input.data() + input.size(), result, options); |
| 13 |
if ((answer.ec != std::errc()) || ((result != 3.1416))) { |
| 14 |
std::cerr << "parsing failure\n"; |
| 15 |
return EXIT_FAILURE; |
| 16 |
} |
| 17 |
std::cout << "parsed the number " << result << std::endl; |
| 18 |
return EXIT_SUCCESS; |
| 19 |
} |