mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-07 01:06:48 +08:00
manually checked modified files for errors, but not committing .clang-format due to the following warning: >>> Setting `QualifierAlignment` to something other than `Leave`, COULD lead to incorrect code formatting due to incorrect decisions made due to clang-formats lack of complete semantic information. As such extra care should be taken to review code changes made by the use of this option.
20 lines
577 B
C++
20 lines
577 B
C++
|
|
#include "fast_float/fast_float.h"
|
|
#include <iostream>
|
|
#include <string>
|
|
#include <system_error>
|
|
|
|
int main() {
|
|
std::string const input = "3,1416 xyz ";
|
|
double result;
|
|
fast_float::parse_options options{fast_float::chars_format::general, ','};
|
|
auto answer = fast_float::from_chars_advanced(
|
|
input.data(), input.data() + input.size(), result, options);
|
|
if ((answer.ec != std::errc()) || ((result != 3.1416))) {
|
|
std::cerr << "parsing failure\n";
|
|
return EXIT_FAILURE;
|
|
}
|
|
std::cout << "parsed the number " << result << std::endl;
|
|
return EXIT_SUCCESS;
|
|
}
|