diff --git a/src/json.hpp b/src/json.hpp index 7f6e2a7a..88266699 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -6262,44 +6262,36 @@ class basic_json } } - template - static T get_from_vector(const std::vector& vec, size_t bytes, size_t current_idx) + template::type = 0> + static constexpr T get_from_vector(const std::vector& vec, const size_t current_idx) { - assert(bytes == 1 or bytes == 2 or bytes == 4 or bytes == 8); - - switch (bytes) - { - case 1: - { - return static_cast(vec[current_idx + 1]); - } - - case 2: - { - return static_cast((static_cast(vec[current_idx + 1]) << 010) + - static_cast(vec[current_idx + 2])); - } - - case 4: - { - return static_cast((static_cast(vec[current_idx + 1]) << 030) + - (static_cast(vec[current_idx + 2]) << 020) + - (static_cast(vec[current_idx + 3]) << 010) + - static_cast(vec[current_idx + 4])); - } - - case 8: - { - return static_cast((static_cast(vec[current_idx + 1]) << 070) + - (static_cast(vec[current_idx + 2]) << 060) + - (static_cast(vec[current_idx + 3]) << 050) + - (static_cast(vec[current_idx + 4]) << 040) + - (static_cast(vec[current_idx + 5]) << 030) + - (static_cast(vec[current_idx + 6]) << 020) + - (static_cast(vec[current_idx + 7]) << 010) + - static_cast(vec[current_idx + 8])); - } - } + return static_cast(vec[current_idx + 1]); + } + template::type = 0> + static constexpr T get_from_vector(const std::vector& vec, const size_t current_idx) + { + return static_cast((static_cast(vec[current_idx + 1]) << 010) + + static_cast(vec[current_idx + 2])); + } + template::type = 0> + static constexpr T get_from_vector(const std::vector& vec, const size_t current_idx) + { + return static_cast((static_cast(vec[current_idx + 1]) << 030) + + (static_cast(vec[current_idx + 2]) << 020) + + (static_cast(vec[current_idx + 3]) << 010) + + static_cast(vec[current_idx + 4])); + } + template::type = 0> + static constexpr T get_from_vector(const std::vector& vec, const size_t current_idx) + { + return static_cast((static_cast(vec[current_idx + 1]) << 070) + + (static_cast(vec[current_idx + 2]) << 060) + + (static_cast(vec[current_idx + 3]) << 050) + + (static_cast(vec[current_idx + 4]) << 040) + + (static_cast(vec[current_idx + 5]) << 030) + + (static_cast(vec[current_idx + 6]) << 020) + + (static_cast(vec[current_idx + 7]) << 010) + + static_cast(vec[current_idx + 8])); } static void to_msgpack_internal(const basic_json& j, std::vector& v) @@ -6847,42 +6839,42 @@ class basic_json else if (v[current_idx] == 0xcc) // uint 8 { idx += 1; // skip content byte - return get_from_vector(v, 1, current_idx); + return get_from_vector(v, current_idx); } else if (v[current_idx] == 0xcd) // uint 16 { idx += 2; // skip 2 content bytes - return get_from_vector(v, 2, current_idx); + return get_from_vector(v, current_idx); } else if (v[current_idx] == 0xce) // uint 32 { idx += 4; // skip 4 content bytes - return get_from_vector(v, 4, current_idx); + return get_from_vector(v, current_idx); } else if (v[current_idx] == 0xcf) // uint 64 { idx += 8; // skip 8 content bytes - return get_from_vector(v, 8, current_idx); + return get_from_vector(v, current_idx); } else if (v[current_idx] == 0xd0) // int 8 { idx += 1; // skip content byte - return get_from_vector(v, 1, current_idx); + return get_from_vector(v, current_idx); } else if (v[current_idx] == 0xd1) // int 16 { idx += 2; // skip 2 content bytes - return get_from_vector(v, 2, current_idx); + return get_from_vector(v, current_idx); } else if (v[current_idx] == 0xd2) // int 32 { idx += 4; // skip 4 content bytes - return get_from_vector(v, 4, current_idx); + return get_from_vector(v, current_idx); } else if (v[current_idx] == 0xd3) // int 64 { idx += 8; // skip 8 content bytes - return get_from_vector(v, 8, current_idx); + return get_from_vector(v, current_idx); } else if (v[current_idx] >= 0xd4 and v[current_idx] <= 0xd8) // fixext { @@ -6890,21 +6882,21 @@ class basic_json } else if (v[current_idx] == 0xd9) // str 8 { - const size_t len = get_from_vector(v, 1, current_idx); + const auto len = get_from_vector(v, current_idx); const size_t offset = current_idx + 2; idx += len + 1; // skip size byte + content bytes return std::string(reinterpret_cast(v.data()) + offset, len); } else if (v[current_idx] == 0xda) // str 16 { - const size_t len = get_from_vector(v, 2, current_idx); + const auto len = get_from_vector(v, current_idx); const size_t offset = current_idx + 3; idx += len + 2; // skip 2 size bytes + content bytes return std::string(reinterpret_cast(v.data()) + offset, len); } else if (v[current_idx] == 0xdb) // str 32 { - const size_t len = get_from_vector(v, 4, current_idx); + const auto len = get_from_vector(v, current_idx); const size_t offset = current_idx + 5; idx += len + 4; // skip 4 size bytes + content bytes return std::string(reinterpret_cast(v.data()) + offset, len); @@ -6912,7 +6904,7 @@ class basic_json else if (v[current_idx] == 0xdc) // array 16 { basic_json result = value_t::array; - const size_t len = get_from_vector(v, 2, current_idx); + const auto len = get_from_vector(v, current_idx); idx += 2; // skip 2 size bytes for (size_t i = 0; i < len; ++i) { @@ -6923,7 +6915,7 @@ class basic_json else if (v[current_idx] == 0xdd) // array 32 { basic_json result = value_t::array; - const size_t len = get_from_vector(v, 4, current_idx); + const auto len = get_from_vector(v, current_idx); idx += 4; // skip 4 size bytes for (size_t i = 0; i < len; ++i) { @@ -6934,7 +6926,7 @@ class basic_json else if (v[current_idx] == 0xde) // map 16 { basic_json result = value_t::object; - const size_t len = get_from_vector(v, 2, current_idx); + const auto len = get_from_vector(v, current_idx); idx += 2; // skip 2 size bytes for (size_t i = 0; i < len; ++i) { @@ -6946,7 +6938,7 @@ class basic_json else if (v[current_idx] == 0xdf) // map 32 { basic_json result = value_t::object; - const size_t len = get_from_vector(v, 4, current_idx); + const auto len = get_from_vector(v, current_idx); idx += 4; // skip 4 size bytes for (size_t i = 0; i < len; ++i) { @@ -6975,22 +6967,22 @@ class basic_json else if (v[current_idx] == 0x18) // Unsigned integer uint8_t { idx += 1; // skip content byte - return get_from_vector(v, 1, current_idx); + return get_from_vector(v, current_idx); } else if (v[current_idx] == 0x19) // Unsigned integer uint16_t { idx += 2; // skip 2 content bytes - return get_from_vector(v, 2, current_idx); + return get_from_vector(v, current_idx); } else if (v[current_idx] == 0x1a) // Unsigned integer uint32_t { idx += 4; // skip 4 content bytes - return get_from_vector(v, 4, current_idx); + return get_from_vector(v, current_idx); } else if (v[current_idx] == 0x1b) // Unsigned integer uint64_t { idx += 8; // skip 8 content bytes - return get_from_vector(v, 8, current_idx); + return get_from_vector(v, current_idx); } else if (v[current_idx] >= 0x20 and v[current_idx] <= 0x37) // Negative integer { @@ -6999,23 +6991,23 @@ class basic_json else if (v[current_idx] == 0x38) // Negative integer { idx += 1; // skip content byte - // must be int64_t ! - return -1 - get_from_vector(v, 1, current_idx); + // must be uint8_t ! + return -1 - get_from_vector(v, current_idx); } else if (v[current_idx] == 0x39) // Negative integer { idx += 2; // skip 2 content bytes - return -1 - get_from_vector(v, 2, current_idx); + return -1 - get_from_vector(v, current_idx); } else if (v[current_idx] == 0x3a) // Negative integer { idx += 4; // skip 4 content bytes - return -1 - get_from_vector(v, 4, current_idx); + return -1 - get_from_vector(v, current_idx); } else if (v[current_idx] == 0x3b) // Negative integer { idx += 8; // skip 8 content bytes - return -1 - get_from_vector(v, 8, current_idx); + return -1 - get_from_vector(v, current_idx); } else if (v[current_idx] >= 0x60 and v[current_idx] <= 0x77) // UTF-8 string { @@ -7026,28 +7018,28 @@ class basic_json } else if (v[current_idx] == 0x78) // UTF-8 string { - const size_t len = get_from_vector(v, 1, current_idx); + const auto len = get_from_vector(v, current_idx); const size_t offset = current_idx + 2; idx += len + 1; // skip size byte + content bytes return std::string(reinterpret_cast(v.data()) + offset, len); } else if (v[current_idx] == 0x79) // UTF-8 string { - const size_t len = get_from_vector(v, 2, current_idx); + const auto len = get_from_vector(v, current_idx); const size_t offset = current_idx + 3; idx += len + 2; // skip 2 size bytes + content bytes return std::string(reinterpret_cast(v.data()) + offset, len); } else if (v[current_idx] == 0x7a) // UTF-8 string { - const size_t len = get_from_vector(v, 4, current_idx); + const auto len = get_from_vector(v, current_idx); const size_t offset = current_idx + 5; idx += len + 4; // skip 4 size bytes + content bytes return std::string(reinterpret_cast(v.data()) + offset, len); } else if (v[current_idx] == 0x7b) // UTF-8 string { - const size_t len = get_from_vector(v, 8, current_idx); + const auto len = get_from_vector(v, current_idx); const size_t offset = current_idx + 9; idx += len + 8; // skip 8 size bytes + content bytes return std::string(reinterpret_cast(v.data()) + offset, len); @@ -7065,7 +7057,7 @@ class basic_json else if (v[current_idx] == 0x98) // array { basic_json result = value_t::array; - const size_t len = get_from_vector(v, 1, current_idx); + const auto len = get_from_vector(v, current_idx); idx += 1; // skip 1 size byte for (size_t i = 0; i < len; ++i) { @@ -7076,7 +7068,7 @@ class basic_json else if (v[current_idx] == 0x99) // array { basic_json result = value_t::array; - const size_t len = get_from_vector(v, 2, current_idx); + const auto len = get_from_vector(v, current_idx); idx += 2; // skip 4 size bytes for (size_t i = 0; i < len; ++i) { @@ -7087,7 +7079,7 @@ class basic_json else if (v[current_idx] == 0x9a) // array { basic_json result = value_t::array; - const size_t len = get_from_vector(v, 4, current_idx); + const auto len = get_from_vector(v, current_idx); idx += 4; // skip 4 size bytes for (size_t i = 0; i < len; ++i) { @@ -7098,7 +7090,7 @@ class basic_json else if (v[current_idx] == 0x9b) // array { basic_json result = value_t::array; - const size_t len = get_from_vector(v, 8, current_idx); + const auto len = get_from_vector(v, current_idx); idx += 8; // skip 8 size bytes for (size_t i = 0; i < len; ++i) { @@ -7120,7 +7112,7 @@ class basic_json else if (v[current_idx] == 0xb8) // map { basic_json result = value_t::object; - const size_t len = get_from_vector(v, 1, current_idx); + const auto len = get_from_vector(v, current_idx); idx += 1; // skip 1 size byte for (size_t i = 0; i < len; ++i) { @@ -7132,7 +7124,7 @@ class basic_json else if (v[current_idx] == 0xb9) // map { basic_json result = value_t::object; - const size_t len = get_from_vector(v, 2, current_idx); + const auto len = get_from_vector(v, current_idx); idx += 2; // skip 2 size bytes for (size_t i = 0; i < len; ++i) { @@ -7144,7 +7136,7 @@ class basic_json else if (v[current_idx] == 0xba) // map { basic_json result = value_t::object; - const size_t len = get_from_vector(v, 4, current_idx); + const auto len = get_from_vector(v, current_idx); idx += 4; // skip 4 size bytes for (size_t i = 0; i < len; ++i) { @@ -7156,7 +7148,7 @@ class basic_json else if (v[current_idx] == 0xbb) // map { basic_json result = value_t::object; - const size_t len = get_from_vector(v, 8, current_idx); + const auto len = get_from_vector(v, current_idx); idx += 8; // skip 8 size bytes for (size_t i = 0; i < len; ++i) { diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 7daf9c49..027218ee 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -6262,44 +6262,36 @@ class basic_json } } - template - static T get_from_vector(const std::vector& vec, size_t bytes, size_t current_idx) + template::type = 0> + static constexpr T get_from_vector(const std::vector& vec, const size_t current_idx) { - assert(bytes == 1 or bytes == 2 or bytes == 4 or bytes == 8); - - switch (bytes) - { - case 1: - { - return static_cast(vec[current_idx + 1]); - } - - case 2: - { - return static_cast((static_cast(vec[current_idx + 1]) << 010) + - static_cast(vec[current_idx + 2])); - } - - case 4: - { - return static_cast((static_cast(vec[current_idx + 1]) << 030) + - (static_cast(vec[current_idx + 2]) << 020) + - (static_cast(vec[current_idx + 3]) << 010) + - static_cast(vec[current_idx + 4])); - } - - case 8: - { - return static_cast((static_cast(vec[current_idx + 1]) << 070) + - (static_cast(vec[current_idx + 2]) << 060) + - (static_cast(vec[current_idx + 3]) << 050) + - (static_cast(vec[current_idx + 4]) << 040) + - (static_cast(vec[current_idx + 5]) << 030) + - (static_cast(vec[current_idx + 6]) << 020) + - (static_cast(vec[current_idx + 7]) << 010) + - static_cast(vec[current_idx + 8])); - } - } + return static_cast(vec[current_idx + 1]); + } + template::type = 0> + static constexpr T get_from_vector(const std::vector& vec, const size_t current_idx) + { + return static_cast((static_cast(vec[current_idx + 1]) << 010) + + static_cast(vec[current_idx + 2])); + } + template::type = 0> + static constexpr T get_from_vector(const std::vector& vec, const size_t current_idx) + { + return static_cast((static_cast(vec[current_idx + 1]) << 030) + + (static_cast(vec[current_idx + 2]) << 020) + + (static_cast(vec[current_idx + 3]) << 010) + + static_cast(vec[current_idx + 4])); + } + template::type = 0> + static constexpr T get_from_vector(const std::vector& vec, const size_t current_idx) + { + return static_cast((static_cast(vec[current_idx + 1]) << 070) + + (static_cast(vec[current_idx + 2]) << 060) + + (static_cast(vec[current_idx + 3]) << 050) + + (static_cast(vec[current_idx + 4]) << 040) + + (static_cast(vec[current_idx + 5]) << 030) + + (static_cast(vec[current_idx + 6]) << 020) + + (static_cast(vec[current_idx + 7]) << 010) + + static_cast(vec[current_idx + 8])); } static void to_msgpack_internal(const basic_json& j, std::vector& v) @@ -6847,42 +6839,42 @@ class basic_json else if (v[current_idx] == 0xcc) // uint 8 { idx += 1; // skip content byte - return get_from_vector(v, 1, current_idx); + return get_from_vector(v, current_idx); } else if (v[current_idx] == 0xcd) // uint 16 { idx += 2; // skip 2 content bytes - return get_from_vector(v, 2, current_idx); + return get_from_vector(v, current_idx); } else if (v[current_idx] == 0xce) // uint 32 { idx += 4; // skip 4 content bytes - return get_from_vector(v, 4, current_idx); + return get_from_vector(v, current_idx); } else if (v[current_idx] == 0xcf) // uint 64 { idx += 8; // skip 8 content bytes - return get_from_vector(v, 8, current_idx); + return get_from_vector(v, current_idx); } else if (v[current_idx] == 0xd0) // int 8 { idx += 1; // skip content byte - return get_from_vector(v, 1, current_idx); + return get_from_vector(v, current_idx); } else if (v[current_idx] == 0xd1) // int 16 { idx += 2; // skip 2 content bytes - return get_from_vector(v, 2, current_idx); + return get_from_vector(v, current_idx); } else if (v[current_idx] == 0xd2) // int 32 { idx += 4; // skip 4 content bytes - return get_from_vector(v, 4, current_idx); + return get_from_vector(v, current_idx); } else if (v[current_idx] == 0xd3) // int 64 { idx += 8; // skip 8 content bytes - return get_from_vector(v, 8, current_idx); + return get_from_vector(v, current_idx); } else if (v[current_idx] >= 0xd4 and v[current_idx] <= 0xd8) // fixext { @@ -6890,21 +6882,21 @@ class basic_json } else if (v[current_idx] == 0xd9) // str 8 { - const size_t len = get_from_vector(v, 1, current_idx); + const auto len = get_from_vector(v, current_idx); const size_t offset = current_idx + 2; idx += len + 1; // skip size byte + content bytes return std::string(reinterpret_cast(v.data()) + offset, len); } else if (v[current_idx] == 0xda) // str 16 { - const size_t len = get_from_vector(v, 2, current_idx); + const auto len = get_from_vector(v, current_idx); const size_t offset = current_idx + 3; idx += len + 2; // skip 2 size bytes + content bytes return std::string(reinterpret_cast(v.data()) + offset, len); } else if (v[current_idx] == 0xdb) // str 32 { - const size_t len = get_from_vector(v, 4, current_idx); + const auto len = get_from_vector(v, current_idx); const size_t offset = current_idx + 5; idx += len + 4; // skip 4 size bytes + content bytes return std::string(reinterpret_cast(v.data()) + offset, len); @@ -6912,7 +6904,7 @@ class basic_json else if (v[current_idx] == 0xdc) // array 16 { basic_json result = value_t::array; - const size_t len = get_from_vector(v, 2, current_idx); + const auto len = get_from_vector(v, current_idx); idx += 2; // skip 2 size bytes for (size_t i = 0; i < len; ++i) { @@ -6923,7 +6915,7 @@ class basic_json else if (v[current_idx] == 0xdd) // array 32 { basic_json result = value_t::array; - const size_t len = get_from_vector(v, 4, current_idx); + const auto len = get_from_vector(v, current_idx); idx += 4; // skip 4 size bytes for (size_t i = 0; i < len; ++i) { @@ -6934,7 +6926,7 @@ class basic_json else if (v[current_idx] == 0xde) // map 16 { basic_json result = value_t::object; - const size_t len = get_from_vector(v, 2, current_idx); + const auto len = get_from_vector(v, current_idx); idx += 2; // skip 2 size bytes for (size_t i = 0; i < len; ++i) { @@ -6946,7 +6938,7 @@ class basic_json else if (v[current_idx] == 0xdf) // map 32 { basic_json result = value_t::object; - const size_t len = get_from_vector(v, 4, current_idx); + const auto len = get_from_vector(v, current_idx); idx += 4; // skip 4 size bytes for (size_t i = 0; i < len; ++i) { @@ -6975,22 +6967,22 @@ class basic_json else if (v[current_idx] == 0x18) // Unsigned integer uint8_t { idx += 1; // skip content byte - return get_from_vector(v, 1, current_idx); + return get_from_vector(v, current_idx); } else if (v[current_idx] == 0x19) // Unsigned integer uint16_t { idx += 2; // skip 2 content bytes - return get_from_vector(v, 2, current_idx); + return get_from_vector(v, current_idx); } else if (v[current_idx] == 0x1a) // Unsigned integer uint32_t { idx += 4; // skip 4 content bytes - return get_from_vector(v, 4, current_idx); + return get_from_vector(v, current_idx); } else if (v[current_idx] == 0x1b) // Unsigned integer uint64_t { idx += 8; // skip 8 content bytes - return get_from_vector(v, 8, current_idx); + return get_from_vector(v, current_idx); } else if (v[current_idx] >= 0x20 and v[current_idx] <= 0x37) // Negative integer { @@ -6999,23 +6991,23 @@ class basic_json else if (v[current_idx] == 0x38) // Negative integer { idx += 1; // skip content byte - // must be int64_t ! - return -1 - get_from_vector(v, 1, current_idx); + // must be uint8_t ! + return -1 - get_from_vector(v, current_idx); } else if (v[current_idx] == 0x39) // Negative integer { idx += 2; // skip 2 content bytes - return -1 - get_from_vector(v, 2, current_idx); + return -1 - get_from_vector(v, current_idx); } else if (v[current_idx] == 0x3a) // Negative integer { idx += 4; // skip 4 content bytes - return -1 - get_from_vector(v, 4, current_idx); + return -1 - get_from_vector(v, current_idx); } else if (v[current_idx] == 0x3b) // Negative integer { idx += 8; // skip 8 content bytes - return -1 - get_from_vector(v, 8, current_idx); + return -1 - get_from_vector(v, current_idx); } else if (v[current_idx] >= 0x60 and v[current_idx] <= 0x77) // UTF-8 string { @@ -7026,28 +7018,28 @@ class basic_json } else if (v[current_idx] == 0x78) // UTF-8 string { - const size_t len = get_from_vector(v, 1, current_idx); + const auto len = get_from_vector(v, current_idx); const size_t offset = current_idx + 2; idx += len + 1; // skip size byte + content bytes return std::string(reinterpret_cast(v.data()) + offset, len); } else if (v[current_idx] == 0x79) // UTF-8 string { - const size_t len = get_from_vector(v, 2, current_idx); + const auto len = get_from_vector(v, current_idx); const size_t offset = current_idx + 3; idx += len + 2; // skip 2 size bytes + content bytes return std::string(reinterpret_cast(v.data()) + offset, len); } else if (v[current_idx] == 0x7a) // UTF-8 string { - const size_t len = get_from_vector(v, 4, current_idx); + const auto len = get_from_vector(v, current_idx); const size_t offset = current_idx + 5; idx += len + 4; // skip 4 size bytes + content bytes return std::string(reinterpret_cast(v.data()) + offset, len); } else if (v[current_idx] == 0x7b) // UTF-8 string { - const size_t len = get_from_vector(v, 8, current_idx); + const auto len = get_from_vector(v, current_idx); const size_t offset = current_idx + 9; idx += len + 8; // skip 8 size bytes + content bytes return std::string(reinterpret_cast(v.data()) + offset, len); @@ -7065,7 +7057,7 @@ class basic_json else if (v[current_idx] == 0x98) // array { basic_json result = value_t::array; - const size_t len = get_from_vector(v, 1, current_idx); + const auto len = get_from_vector(v, current_idx); idx += 1; // skip 1 size byte for (size_t i = 0; i < len; ++i) { @@ -7076,7 +7068,7 @@ class basic_json else if (v[current_idx] == 0x99) // array { basic_json result = value_t::array; - const size_t len = get_from_vector(v, 2, current_idx); + const auto len = get_from_vector(v, current_idx); idx += 2; // skip 4 size bytes for (size_t i = 0; i < len; ++i) { @@ -7087,7 +7079,7 @@ class basic_json else if (v[current_idx] == 0x9a) // array { basic_json result = value_t::array; - const size_t len = get_from_vector(v, 4, current_idx); + const auto len = get_from_vector(v, current_idx); idx += 4; // skip 4 size bytes for (size_t i = 0; i < len; ++i) { @@ -7098,7 +7090,7 @@ class basic_json else if (v[current_idx] == 0x9b) // array { basic_json result = value_t::array; - const size_t len = get_from_vector(v, 8, current_idx); + const auto len = get_from_vector(v, current_idx); idx += 8; // skip 8 size bytes for (size_t i = 0; i < len; ++i) { @@ -7120,7 +7112,7 @@ class basic_json else if (v[current_idx] == 0xb8) // map { basic_json result = value_t::object; - const size_t len = get_from_vector(v, 1, current_idx); + const auto len = get_from_vector(v, current_idx); idx += 1; // skip 1 size byte for (size_t i = 0; i < len; ++i) { @@ -7132,7 +7124,7 @@ class basic_json else if (v[current_idx] == 0xb9) // map { basic_json result = value_t::object; - const size_t len = get_from_vector(v, 2, current_idx); + const auto len = get_from_vector(v, current_idx); idx += 2; // skip 2 size bytes for (size_t i = 0; i < len; ++i) { @@ -7144,7 +7136,7 @@ class basic_json else if (v[current_idx] == 0xba) // map { basic_json result = value_t::object; - const size_t len = get_from_vector(v, 4, current_idx); + const auto len = get_from_vector(v, current_idx); idx += 4; // skip 4 size bytes for (size_t i = 0; i < len; ++i) { @@ -7156,7 +7148,7 @@ class basic_json else if (v[current_idx] == 0xbb) // map { basic_json result = value_t::object; - const size_t len = get_from_vector(v, 8, current_idx); + const auto len = get_from_vector(v, current_idx); idx += 8; // skip 8 size bytes for (size_t i = 0; i < len; ++i) {