Skip to content

Commit f632e7c

Browse files
committed
Put C++11 capable version back, change name to readme style
1 parent 0655a13 commit f632e7c

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

doc/basics.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ The next two functions will take as input a JSON document containing an array wi
405405
```C++
406406
simdjson::dom::parser parser{};
407407
408-
bool ParseDouble(const char *j, double &d) {
408+
bool parse_double(const char *j, double &d) {
409409
simdjson::error_code error;
410410
parser.parse(j, std::strlen(j))
411411
.at(0)
@@ -415,10 +415,13 @@ bool ParseDouble(const char *j, double &d) {
415415
return true;
416416
}
417417
418-
bool ParseString(const char *j, std::string &s) {
419-
auto [answer, error] = parser.parse(j,strlen(j))
418+
bool parse_string(const char *j, std::string &s) {
419+
simdjson::error_code error;
420+
std::string_view answer;
421+
parser.parse(j,strlen(j))
420422
.at(0)
421-
.get<std::string_view>();
423+
.get<std::string_view>()
424+
.tie(answer, error);
422425
if (error) { return false; }
423426
s.assign(answer.data(), answer.size());
424427
return true;

tests/readme_examples_noexceptions.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -199,16 +199,6 @@ bool ParseDouble(const char *j, double &d) {
199199
}
200200

201201
// See https://github.com/miloyip/nativejson-benchmark/blob/master/src/tests/simdjsontest.cpp
202-
#ifdef SIMDJSON_CPLUSPLUS17
203-
bool ParseString(const char *j, std::string &s) {
204-
auto [answer, error] = parser.parse(j,strlen(j))
205-
.at(0)
206-
.get<std::string_view>();
207-
if (error) { return false; }
208-
s.assign(answer.data(), answer.size());
209-
return true;
210-
}
211-
#else
212202
bool ParseString(const char *j, std::string &s) {
213203
simdjson::error_code error;
214204
std::string_view answer;
@@ -220,7 +210,6 @@ bool ParseString(const char *j, std::string &s) {
220210
s.assign(answer.data(), answer.size());
221211
return true;
222212
}
223-
#endif
224213

225214

226215
int main() {

0 commit comments

Comments
 (0)