Skip to content

Commit 447ee0b

Browse files
committed
updating documentation
1 parent 0458c20 commit 447ee0b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Example:
5757
```C++
5858
#include "fast_float/fast_float.h"
5959
#include <iostream>
60+
#include <string>
6061
6162
int main() {
6263
std::string input = "3.1416 xyz ";
@@ -68,6 +69,25 @@ int main() {
6869
}
6970
```
7071

72+
Though the C++17 standard has you do a comparison with `std::errc()` to check whether the conversion worked, you can avoid it by casting the result to a `bool` like so:
73+
74+
```cpp
75+
#include "fast_float/fast_float.h"
76+
#include <iostream>
77+
#include <string>
78+
79+
int main() {
80+
std::string input = "3.1416 xyz ";
81+
double result;
82+
if(auto answer = fast_float::from_chars(input.data(), input.data() + input.size(), result)) {
83+
std::cout << "parsed the number " << result << std::endl;
84+
return EXIT_SUCCESS;
85+
}
86+
std::cerr << "failed to parse " << result << std::endl;
87+
return EXIT_FAILURE;
88+
}
89+
```
90+
7191
You can parse delimited numbers:
7292

7393
```C++

0 commit comments

Comments
 (0)