Compile examples from implementation-selection.md

This commit is contained in:
John Keiser 2020-03-29 16:15:22 -07:00
parent 7ed65e42d7
commit 0e3453f7c2
1 changed files with 20 additions and 3 deletions

View File

@ -1,8 +1,6 @@
#include <iostream>
#include "simdjson.h"
namespace compile_tests {
using namespace std;
using namespace simdjson;
using error_code=simdjson::error_code;
@ -74,7 +72,26 @@ void basics_ndjson() {
// Prints 1 2 3
}
} // namespace basics
void implementation_selection_1() {
cout << "simdjson v" << STRINGIFY(SIMDJSON_VERSION) << endl;
cout << "Detected the best implementation for your machine: " << simdjson::active_implementation->name();
cout << "(" << simdjson::active_implementation->description() << ")" << endl;
}
void implementation_selection_2() {
for (auto implementation : simdjson::available_implementations) {
cout << implementation->name() << ": " << implementation->description() << endl;
}
}
void implementation_selection_3() {
cout << simdjson::available_implementations["fallback"]->description() << endl;
}
void implementation_selection_4() {
// Use the fallback implementation, even though my machine is fast enough for anything
simdjson::active_implementation = simdjson::available_implementations["fallback"];
}
int main() {
return 0;