mirror of
https://github.com/nlohmann/json.git
synced 2025-06-11 04:12:56 +08:00
Use binary_t::value_type (#4805)
This commit is contained in:
parent
b19f058465
commit
cf16c5ab9f
@ -2944,7 +2944,7 @@ class binary_reader
|
|||||||
success = false;
|
success = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
result.push_back(static_cast<std::uint8_t>(current));
|
result.push_back(static_cast<typename binary_t::value_type>(current));
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
@ -12765,7 +12765,7 @@ class binary_reader
|
|||||||
success = false;
|
success = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
result.push_back(static_cast<std::uint8_t>(current));
|
result.push_back(static_cast<typename binary_t::value_type>(current));
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,22 @@ using ordered_json = nlohmann::ordered_json;
|
|||||||
#elif __has_include(<experimental/optional>)
|
#elif __has_include(<experimental/optional>)
|
||||||
#include <experimental/optional>
|
#include <experimental/optional>
|
||||||
#endif
|
#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
|
#endif
|
||||||
|
|
||||||
#ifdef JSON_HAS_CPP_20
|
#ifdef JSON_HAS_CPP_20
|
||||||
@ -1094,6 +1110,15 @@ TEST_CASE("regression tests 2")
|
|||||||
CHECK(j.type_name() == "invalid");
|
CHECK(j.type_name() == "invalid");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef JSON_HAS_CPP_17
|
||||||
|
SECTION("issue #4804: from_cbor incompatible with std::vector<std::byte> as binary_t")
|
||||||
|
{
|
||||||
|
const std::vector<std::uint8_t> data = {0x80};
|
||||||
|
const auto decoded = json_4804::from_cbor(data);
|
||||||
|
CHECK((decoded == json_4804::array()));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE_TEMPLATE("issue #4798 - nlohmann::json::to_msgpack() encode float NaN as double", T, double, float) // NOLINT(readability-math-missing-parentheses)
|
TEST_CASE_TEMPLATE("issue #4798 - nlohmann::json::to_msgpack() encode float NaN as double", T, double, float) // NOLINT(readability-math-missing-parentheses)
|
||||||
|
Loading…
Reference in New Issue
Block a user