mirror of
https://github.com/nlohmann/json.git
synced 2025-06-07 19:42:48 +08:00
🐛 use binary_t::value_type
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
parent
64ebc6d511
commit
9e6240ad02
@ -2944,7 +2944,7 @@ class binary_reader
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
result.push_back(static_cast<std::uint8_t>(current));
|
||||
result.push_back(static_cast<typename binary_t::value_type>(current));
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
@ -12765,7 +12765,7 @@ class binary_reader
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
result.push_back(static_cast<std::uint8_t>(current));
|
||||
result.push_back(static_cast<typename binary_t::value_type>(current));
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
@ -42,6 +42,22 @@ using ordered_json = nlohmann::ordered_json;
|
||||
#elif __has_include(<experimental/optional>)
|
||||
#include <experimental/optional>
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// for #4804
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
using json_4804 = nlohmann::basic_json<std::map, // ObjectType
|
||||
std::vector, // ArrayType
|
||||
std::string, // StringType
|
||||
bool, // BooleanType
|
||||
std::int64_t, // NumberIntegerType
|
||||
std::uint64_t, // NumberUnsignedType
|
||||
double, // NumberFloatType
|
||||
std::allocator, // AllocatorType
|
||||
nlohmann::adl_serializer, // JSONSerializer
|
||||
std::vector<std::byte>, // BinaryType
|
||||
void // CustomBaseClass
|
||||
>;
|
||||
#endif
|
||||
|
||||
#ifdef JSON_HAS_CPP_20
|
||||
@ -1094,6 +1110,14 @@ TEST_CASE("regression tests 2")
|
||||
CHECK(j.type_name() == "invalid");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef JSON_HAS_CPP_17
|
||||
SECTION("issue #4804: from_cbor incompatible with std::vector<std::byte> as binary_t")
|
||||
{
|
||||
const std::vector<char> data;
|
||||
const auto decoded = json_4804::from_cbor(data);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
DOCTEST_CLANG_SUPPRESS_WARNING_POP
|
||||
|
Loading…
Reference in New Issue
Block a user