Merge branch 'custom-integer-types' of https://github.com/eric-wieser/json into custom-integer-types

This commit is contained in:
Eric Wieser 2022-07-11 21:30:34 +00:00
commit 1fc44778f2
2 changed files with 6 additions and 6 deletions

View File

@ -1250,7 +1250,7 @@ scan_number_done:
if (errno == 0)
{
value_unsigned = static_cast<number_unsigned_t>(x);
if (static_cast<typeof(x)>(value_unsigned) == x)
if (static_cast<decltype(x)>(value_unsigned) == x)
{
return token_type::value_unsigned;
}
@ -1266,7 +1266,7 @@ scan_number_done:
if (errno == 0)
{
value_integer = static_cast<number_integer_t>(x);
if (static_cast<typeof(x)>(value_integer) == x)
if (static_cast<decltype(x)>(value_integer) == x)
{
return token_type::value_integer;
}

View File

@ -86,11 +86,11 @@ template<typename T> class std::numeric_limits<wrapped_int<T>>
TEST_CASE("custom integer types")
{
using json = nlohmann::basic_json <
std::map, std::vector, std::string, bool,
wrapped_int<std::int64_t>, wrapped_int<std::uint64_t>, double, std::allocator >;
using my_json = nlohmann::basic_json <
std::map, std::vector, std::string, bool,
wrapped_int<std::int64_t>, wrapped_int<std::uint64_t>, double, std::allocator >;
std::string data = "[1,2,-3,-4]";
json as_json = json::parse(data.begin(), data.end());
my_json as_json = my_json::parse(data.begin(), data.end());
wrapped_int<std::uint64_t> i1 = as_json[1];
wrapped_int<std::int64_t> i2 = as_json[2];
CHECK(i1 == wrapped_int<std::uint64_t>(2));