mirror of
https://github.com/simdjson/simdjson
synced 2026-06-08 17:27:07 +00:00
Standard compatibility fixes (#2053)
* Standard compatibility fixes * missing commit * Should work. * Fix. * Fix. * Should work now. --------- Co-authored-by: Daniel Lemire <dlemire@lemire.me>
This commit is contained in:
@@ -32,4 +32,12 @@
|
||||
#error simdjson requires a compiler compliant with the C++11 standard
|
||||
#endif
|
||||
|
||||
#ifndef SIMDJSON_IF_CONSTEXPR
|
||||
#if SIMDJSON_CPLUSPLUS17
|
||||
#define SIMDJSON_IF_CONSTEXPR if constexpr
|
||||
#else
|
||||
#define SIMDJSON_IF_CONSTEXPR if
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // SIMDJSON_COMPILER_CHECK_H
|
||||
|
||||
@@ -62,8 +62,8 @@ public:
|
||||
template <int START, int N>
|
||||
simdjson_inline int write_indexes(uint32_t idx, uint64_t& bits) {
|
||||
write_index(idx, bits, START);
|
||||
if constexpr (N > 1) {
|
||||
write_indexes<START+1, N-1>(idx, bits);
|
||||
SIMDJSON_IF_CONSTEXPR (N > 1) {
|
||||
write_indexes<(N-1>0?START+1:START), (N-1>=0?N-1:1)>(idx, bits);
|
||||
}
|
||||
return START+N;
|
||||
}
|
||||
@@ -71,9 +71,9 @@ public:
|
||||
template <int START, int END, int STEP>
|
||||
simdjson_inline int write_indexes_stepped(uint32_t idx, uint64_t& bits, int cnt) {
|
||||
write_indexes<START, STEP>(idx, bits);
|
||||
if constexpr ((START+STEP) < END) {
|
||||
SIMDJSON_IF_CONSTEXPR ((START+STEP) < END) {
|
||||
if (simdjson_unlikely((START+STEP) < cnt)) {
|
||||
write_indexes_stepped<START+STEP, END, STEP>(idx, bits, cnt);
|
||||
write_indexes_stepped<(START+STEP<END?START+STEP:END), END, STEP>(idx, bits, cnt);
|
||||
}
|
||||
}
|
||||
return ((END-START) % STEP) == 0 ? END : (END-START) - ((END-START) % STEP) + STEP;
|
||||
@@ -107,7 +107,7 @@ public:
|
||||
static constexpr const int STEP_UNTIL = 24;
|
||||
|
||||
write_indexes_stepped<0, STEP_UNTIL, STEP>(idx, bits, cnt);
|
||||
if constexpr (STEP_UNTIL < 64) {
|
||||
SIMDJSON_IF_CONSTEXPR (STEP_UNTIL < 64) {
|
||||
if (simdjson_unlikely(STEP_UNTIL < cnt)) {
|
||||
for (int i=STEP_UNTIL; i<cnt; i++) {
|
||||
write_index(idx, bits, i);
|
||||
@@ -352,4 +352,4 @@ simdjson_inline error_code json_structural_indexer::finish(dom_parser_implementa
|
||||
// Clear CUSTOM_BIT_INDEXER so other implementations can set it if they need to.
|
||||
#undef SIMDJSON_GENERIC_JSON_STRUCTURAL_INDEXER_CUSTOM_BIT_INDEXER
|
||||
|
||||
#endif // SIMDJSON_SRC_GENERIC_STAGE1_JSON_STRUCTURAL_INDEXER_H
|
||||
#endif // SIMDJSON_SRC_GENERIC_STAGE1_JSON_STRUCTURAL_INDEXER_H
|
||||
|
||||
@@ -170,14 +170,6 @@ using namespace simd;
|
||||
this->error |= this->prev_incomplete;
|
||||
}
|
||||
|
||||
#ifndef SIMDJSON_IF_CONSTEXPR
|
||||
#if SIMDJSON_CPLUSPLUS17
|
||||
#define SIMDJSON_IF_CONSTEXPR if constexpr
|
||||
#else
|
||||
#define SIMDJSON_IF_CONSTEXPR if
|
||||
#endif
|
||||
#endif
|
||||
|
||||
simdjson_inline void check_next_input(const simd8x64<uint8_t>& input) {
|
||||
if(simdjson_likely(is_ascii(input))) {
|
||||
this->error |= this->prev_incomplete;
|
||||
|
||||
@@ -32,7 +32,7 @@ static bool parse_and_validate(const std::string src, T expected) {
|
||||
const padded_string pstr{src};
|
||||
simdjson::dom::parser parser;
|
||||
|
||||
if constexpr (std::is_same<int64_t, T>::value) {
|
||||
SIMDJSON_IF_CONSTEXPR (std::is_same<int64_t, T>::value) {
|
||||
int64_t actual{};
|
||||
ASSERT_SUCCESS( parser.parse(pstr)["key"].get(actual) );
|
||||
std::cout << std::boolalpha << "test: " << (expected == actual) << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user