File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,27 @@ bool many() {
2222 return true ;
2323}
2424
25+
26+ void many_loop () {
27+ const std::string input = " 234532.3426362,7869234.9823,324562.645" ;
28+ double result;
29+ const char * pointer = input.data ();
30+ const char * end_pointer = input.data () + input.size ();
31+
32+ while (pointer < end_pointer) {
33+ auto answer = fast_float::from_chars (pointer, end_pointer, result);
34+ if (answer.ec != std::errc ()) {
35+ std::cerr << " error while parsing" << std::endl;
36+ break ;
37+ }
38+ std::cout << " parsed: " << result << std::endl;
39+ pointer = answer.ptr ;
40+ if ((answer.ptr < end_pointer) && (*pointer == ' ,' )) {
41+ pointer++;
42+ }
43+ }
44+ }
45+
2546int main () {
2647 const std::string input = " 3.1416 xyz " ;
2748 double result;
@@ -33,5 +54,6 @@ int main() {
3354 printf (" Bug\n " );
3455 return EXIT_FAILURE;
3556 }
57+ many_loop ();
3658 return EXIT_SUCCESS;
3759}
You can’t perform that action at this time.
0 commit comments