8000 std::tie does not work on some compilers (#567) · JavaScriptExpert/simdjson@6cefeb3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6cefeb3

Browse files
authored
std::tie does not work on some compilers (simdjson#567)
* std::tie workaround. * Cleaner solution
1 parent f1744f5 commit 6cefeb3

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

benchmark/benchmarker.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ struct benchmarker {
263263
: filename(_filename), collector(_collector), stats(NULL) {
264264
verbose() << "[verbose] loading " << filename << endl;
265265
simdjson::error_code error;
266-
std::tie(this->json, error) = padded_string::load(filename);
266+
padded_string::load(filename).tie(this->json, error);
267267
if (error) {
268268
exit_error(string("Could not load the file ") + filename);
269269
}

include/simdjson/error.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,16 @@ struct simdjson_result : public std::pair<T, error_code> {
128128
*/
129129
template<typename T>
130130
struct simdjson_move_result : std::pair<T, error_code> {
131+
/**
132+
* Move the value and the error to the provided variables.
133+
*/
134+
void tie(T& t, error_code & e) {
135+
// on the clang compiler that comes with current macOS (Apple clang version 11.0.0),
136+
// std::tie(this->json, error) = padded_string::load(filename);
137+
// fails with "benchmark/benchmarker.h:266:33: error: no viable overloaded '='""
138+
t = std::move(this->first);
139+
e = std::move(this->second);
140+
}
131141
/**
132142
* The error.
133143
*/

0 commit comments

Comments
 (0)
0