Skip to content

Commit 0e3453f

Browse files
committed
Compile examples from implementation-selection.md
1 parent 7ed65e4 commit 0e3453f

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

tests/readme_examples.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#include <iostream>
22
#include "simdjson.h"
33

4-
namespace compile_tests {
5-
64
using namespace std;
75
using namespace simdjson;
86
using error_code=simdjson::error_code;
@@ -74,7 +72,26 @@ void basics_ndjson() {
7472
// Prints 1 2 3
7573
}
7674

77-
} // namespace basics
75+
void implementation_selection_1() {
76+
cout << "simdjson v" << STRINGIFY(SIMDJSON_VERSION) << endl;
77+
cout << "Detected the best implementation for your machine: " << simdjson::active_implementation->name();
78+
cout << "(" << simdjson::active_implementation->description() << ")" << endl;
79+
}
80+
81+
void implementation_selection_2() {
82+
for (auto implementation : simdjson::available_implementations) {
83+
cout << implementation->name() << ": " << implementation->description() << endl;
84+
}
85+
}
86+
87+
void implementation_selection_3() {
88+
cout << simdjson::available_implementations["fallback"]->description() << endl;
89+
}
90+
91+
void implementation_selection_4() {
92+
// Use the fallback implementation, even though my machine is fast enough for anything
93+
simdjson::active_implementation = simdjson::available_implementations["fallback"];
94+
}
7895

7996
int main() {
8097
return 0;

0 commit comments

Comments
 (0)