Address review: conjunction/negation trait, astyle-friendly alias, docs table order

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann committed 2026-10-14 17:47:38 +02:00
1 parent d5e51d03c0
commit 2cac35c6ad
3 files changed
+16 -20

No files matched your search

@@ -542,9 +542,9 @@ therefore silently changes parse results rather than raising an error. See
| `#!cpp std::int64_t` / `#!cpp std::uint64_t` (default) | full |
| `#!cpp std::int32_t` / `#!cpp std::uint32_t`, `#!cpp long long` / `#!cpp unsigned long long` | full; narrower types change which literals the parser can represent |
| any other pair of standard signed/unsigned integer types | full |
| class types, enumerations | not usable; `#!cpp std::is_integral` must hold |
| the same signed integer type for both, e.g. `#!cpp std::int64_t` / `#!cpp std::int64_t` | full; every integer is stored as `number_integer_t`, see [above](#same-type-for-both) |
| `#!cpp bool`, or a type already used for another member of the union | not usable; `#!cpp std::is_integral<bool>` is in fact `#!cpp true`, but the `get_impl_ptr` overloads for `boolean_t`, `number_integer_t`, `number_unsigned_t` and `number_float_t` would collide |
| class types, enumerations | not usable; `#!cpp std::is_integral` must hold |
| `#!cpp bool`, `number_float_t`, or the type of another member of the union | not usable; `#!cpp std::is_integral<bool>` is in fact `#!cpp true`, but the `get_impl_ptr` overloads for `boolean_t`, `number_integer_t`, `number_unsigned_t` and `number_float_t` would collide |
## `NumberFloatType`
+7 -9
View File
@@ -692,11 +692,11 @@ struct is_compatible_number_integer_type
// if number_unsigned_t is the same type as number_integer_t, unsigned integers
// are stored as number_integer as well (#2573)
template<typename BasicJsonType, typename CompatibleNumberIntegerType>
struct is_compatible_number_integer_type < BasicJsonType, CompatibleNumberIntegerType,
enable_if_t < std::is_same<typename BasicJsonType::number_integer_t, typename BasicJsonType::number_unsigned_t>::value&&
std::is_integral<CompatibleNumberIntegerType>::value&&
std::is_unsigned<CompatibleNumberIntegerType>::value&&
!std::is_same<bool, CompatibleNumberIntegerType>::value >>
struct is_compatible_number_integer_type<BasicJsonType, CompatibleNumberIntegerType,
enable_if_t<conjunction<std::is_same<typename BasicJsonType::number_integer_t, typename BasicJsonType::number_unsigned_t>,
std::is_integral<CompatibleNumberIntegerType>,
std::is_unsigned<CompatibleNumberIntegerType>,
negation<std::is_same<bool, CompatibleNumberIntegerType>>>::value>>
: std::is_constructible<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType> {};
template<typename BasicJsonType, typename CompatibleType, typename = void>
@@ -1047,10 +1047,8 @@ struct same_as_number_integer_type {};
// types through an incomplete basic_json (MSVC reports a recursive alias, and
// old GCC versions crash)
template<typename NumberIntegerType, typename NumberUnsignedType>
using number_unsigned_overload_type = typename std::conditional <
std::is_same<NumberIntegerType, NumberUnsignedType>::value,
same_as_number_integer_type,
NumberUnsignedType >::type;
using number_unsigned_overload_type = typename std::conditional<std::is_same<NumberIntegerType, NumberUnsignedType>::value,
same_as_number_integer_type, NumberUnsignedType>::type;
// number_unsigned_t of BasicJsonType, or same_as_number_integer_type if it is
// the same type as number_integer_t
+7 -9
View File
@@ -4696,11 +4696,11 @@ struct is_compatible_number_integer_type
// if number_unsigned_t is the same type as number_integer_t, unsigned integers
// are stored as number_integer as well (#2573)
template<typename BasicJsonType, typename CompatibleNumberIntegerType>
struct is_compatible_number_integer_type < BasicJsonType, CompatibleNumberIntegerType,
enable_if_t < std::is_same<typename BasicJsonType::number_integer_t, typename BasicJsonType::number_unsigned_t>::value&&
std::is_integral<CompatibleNumberIntegerType>::value&&
std::is_unsigned<CompatibleNumberIntegerType>::value&&
!std::is_same<bool, CompatibleNumberIntegerType>::value >>
struct is_compatible_number_integer_type<BasicJsonType, CompatibleNumberIntegerType,
enable_if_t<conjunction<std::is_same<typename BasicJsonType::number_integer_t, typename BasicJsonType::number_unsigned_t>,
std::is_integral<CompatibleNumberIntegerType>,
std::is_unsigned<CompatibleNumberIntegerType>,
negation<std::is_same<bool, CompatibleNumberIntegerType>>>::value>>
: std::is_constructible<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType> {};
template<typename BasicJsonType, typename CompatibleType, typename = void>
@@ -5051,10 +5051,8 @@ struct same_as_number_integer_type {};
// types through an incomplete basic_json (MSVC reports a recursive alias, and
// old GCC versions crash)
template<typename NumberIntegerType, typename NumberUnsignedType>
using number_unsigned_overload_type = typename std::conditional <
std::is_same<NumberIntegerType, NumberUnsignedType>::value,
same_as_number_integer_type,
NumberUnsignedType >::type;
using number_unsigned_overload_type = typename std::conditional<std::is_same<NumberIntegerType, NumberUnsignedType>::value,
same_as_number_integer_type, NumberUnsignedType>::type;
// number_unsigned_t of BasicJsonType, or same_as_number_integer_type if it is
// the same type as number_integer_t