Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
json
Commits
c13ecd53
Unverified
Commit
c13ecd53
authored
Jul 13, 2020
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
💚
add trait for 128 bit integers
parent
0f1f5052
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
6 deletions
+14
-6
from_json.hpp
include/nlohmann/detail/conversions/from_json.hpp
+1
-1
type_traits.hpp
include/nlohmann/detail/meta/type_traits.hpp
+7
-2
json.hpp
single_include/nlohmann/json.hpp
+6
-3
No files found.
include/nlohmann/detail/conversions/from_json.hpp
View file @
c13ecd53
...
@@ -34,7 +34,7 @@ void from_json(const BasicJsonType& j, typename std::nullptr_t& n)
...
@@ -34,7 +34,7 @@ void from_json(const BasicJsonType& j, typename std::nullptr_t& n)
// overloads for basic_json template parameters
// overloads for basic_json template parameters
template
<
typename
BasicJsonType
,
typename
ArithmeticType
,
template
<
typename
BasicJsonType
,
typename
ArithmeticType
,
enable_if_t
<
std
::
is_arithmetic
<
ArithmeticType
>::
value
&&
enable_if_t
<
(
std
::
is_arithmetic
<
ArithmeticType
>::
value
||
is_128_bit_integral
<
ArithmeticType
>::
value
)
&&
!
std
::
is_same
<
ArithmeticType
,
typename
BasicJsonType
::
boolean_t
>::
value
,
!
std
::
is_same
<
ArithmeticType
,
typename
BasicJsonType
::
boolean_t
>::
value
,
int
>
=
0
>
int
>
=
0
>
void
get_arithmetic_value
(
const
BasicJsonType
&
j
,
ArithmeticType
&
val
)
void
get_arithmetic_value
(
const
BasicJsonType
&
j
,
ArithmeticType
&
val
)
...
...
include/nlohmann/detail/meta/type_traits.hpp
View file @
c13ecd53
...
@@ -327,10 +327,16 @@ template<typename BasicJsonType, typename ConstructibleArrayType>
...
@@ -327,10 +327,16 @@ template<typename BasicJsonType, typename ConstructibleArrayType>
struct
is_constructible_array_type
struct
is_constructible_array_type
:
is_constructible_array_type_impl
<
BasicJsonType
,
ConstructibleArrayType
>
{};
:
is_constructible_array_type_impl
<
BasicJsonType
,
ConstructibleArrayType
>
{};
// true for types with up to 64 bit
template
<
typename
NumberType
>
template
<
typename
NumberType
>
struct
is_64_bit
:
std
::
integral_constant
<
bool
,
(
sizeof
(
NumberType
)
<=
8
)
>
struct
is_64_bit
:
std
::
integral_constant
<
bool
,
(
sizeof
(
NumberType
)
<=
8
)
>
{};
{};
// true for types with at least 64 bit that con be convert from 64 bit integers
template
<
typename
NumberType
>
struct
is_128_bit_integral
:
std
::
integral_constant
<
bool
,
(((
std
::
is_signed
<
NumberType
>::
value
&&
std
::
is_convertible
<
std
::
int64_t
,
NumberType
>::
value
)
||
(
std
::
is_unsigned
<
NumberType
>::
value
&&
std
::
is_convertible
<
std
::
uint64_t
,
NumberType
>::
value
))
&&
!
is_64_bit
<
NumberType
>::
value
)
>
{};
template
<
typename
RealIntegerType
,
typename
CompatibleNumberIntegerType
,
template
<
typename
RealIntegerType
,
typename
CompatibleNumberIntegerType
,
typename
=
void
>
typename
=
void
>
struct
is_compatible_integer_type_impl
:
std
::
false_type
{};
struct
is_compatible_integer_type_impl
:
std
::
false_type
{};
...
@@ -358,8 +364,7 @@ template<typename RealIntegerType, typename CompatibleNumberIntegerType>
...
@@ -358,8 +364,7 @@ template<typename RealIntegerType, typename CompatibleNumberIntegerType>
struct
is_compatible_integer_type_impl
<
RealIntegerType
,
CompatibleNumberIntegerType
,
struct
is_compatible_integer_type_impl
<
RealIntegerType
,
CompatibleNumberIntegerType
,
enable_if_t
<
std
::
is_same
<
RealIntegerType
,
CompatibleNumberIntegerType
>::
value
&&
enable_if_t
<
std
::
is_same
<
RealIntegerType
,
CompatibleNumberIntegerType
>::
value
&&
!
std
::
is_integral
<
CompatibleNumberIntegerType
>::
value
&&
!
std
::
is_integral
<
CompatibleNumberIntegerType
>::
value
&&
(
std
::
is_unsigned
<
RealIntegerType
>::
value
&&
std
::
is_convertible
<
std
::
uint64_t
,
RealIntegerType
>::
value
||
!
std
::
is_unsigned
<
RealIntegerType
>::
value
&&
std
::
is_convertible
<
std
::
int64_t
,
RealIntegerType
>::
value
)
&&
is_128_bit_integral
<
CompatibleNumberIntegerType
>::
value
>>
!
is_64_bit
<
RealIntegerType
>::
value
>>
{
{
static
constexpr
auto
value
=
true
;
static
constexpr
auto
value
=
true
;
};
};
...
...
single_include/nlohmann/json.hpp
View file @
c13ecd53
...
@@ -3146,6 +3146,10 @@ template<typename NumberType>
...
@@ -3146,6 +3146,10 @@ template<typename NumberType>
struct
is_64_bit
:
std
::
integral_constant
<
bool
,
(
sizeof
(
NumberType
)
<=
8
)
>
struct
is_64_bit
:
std
::
integral_constant
<
bool
,
(
sizeof
(
NumberType
)
<=
8
)
>
{};
{};
template
<
typename
NumberType
>
struct
is_128_bit_integral
:
std
::
integral_constant
<
bool
,
(((
std
::
is_signed
<
NumberType
>::
value
&&
std
::
is_convertible
<
std
::
int64_t
,
NumberType
>::
value
)
||
(
std
::
is_unsigned
<
NumberType
>::
value
&&
std
::
is_convertible
<
std
::
uint64_t
,
NumberType
>::
value
))
&&
!
is_64_bit
<
NumberType
>::
value
)
>
{};
template
<
typename
RealIntegerType
,
typename
CompatibleNumberIntegerType
,
template
<
typename
RealIntegerType
,
typename
CompatibleNumberIntegerType
,
typename
=
void
>
typename
=
void
>
struct
is_compatible_integer_type_impl
:
std
::
false_type
{};
struct
is_compatible_integer_type_impl
:
std
::
false_type
{};
...
@@ -3173,8 +3177,7 @@ template<typename RealIntegerType, typename CompatibleNumberIntegerType>
...
@@ -3173,8 +3177,7 @@ template<typename RealIntegerType, typename CompatibleNumberIntegerType>
struct
is_compatible_integer_type_impl
<
RealIntegerType
,
CompatibleNumberIntegerType
,
struct
is_compatible_integer_type_impl
<
RealIntegerType
,
CompatibleNumberIntegerType
,
enable_if_t
<
std
::
is_same
<
RealIntegerType
,
CompatibleNumberIntegerType
>::
value
&&
enable_if_t
<
std
::
is_same
<
RealIntegerType
,
CompatibleNumberIntegerType
>::
value
&&
!
std
::
is_integral
<
CompatibleNumberIntegerType
>::
value
&&
!
std
::
is_integral
<
CompatibleNumberIntegerType
>::
value
&&
(
std
::
is_unsigned
<
RealIntegerType
>::
value
&&
std
::
is_convertible
<
std
::
uint64_t
,
RealIntegerType
>::
value
||
!
std
::
is_unsigned
<
RealIntegerType
>::
value
&&
std
::
is_convertible
<
std
::
int64_t
,
RealIntegerType
>::
value
)
&&
is_128_bit_integral
<
CompatibleNumberIntegerType
>::
value
>>
!
is_64_bit
<
RealIntegerType
>::
value
>>
{
{
static
constexpr
auto
value
=
true
;
static
constexpr
auto
value
=
true
;
};
};
...
@@ -3315,7 +3318,7 @@ void from_json(const BasicJsonType& j, typename std::nullptr_t& n)
...
@@ -3315,7 +3318,7 @@ void from_json(const BasicJsonType& j, typename std::nullptr_t& n)
// overloads for basic_json template parameters
// overloads for basic_json template parameters
template
<
typename
BasicJsonType
,
typename
ArithmeticType
,
template
<
typename
BasicJsonType
,
typename
ArithmeticType
,
enable_if_t
<
std
::
is_arithmetic
<
ArithmeticType
>::
value
&&
enable_if_t
<
(
std
::
is_arithmetic
<
ArithmeticType
>::
value
||
is_128_bit_integral
<
ArithmeticType
>::
value
)
&&
!
std
::
is_same
<
ArithmeticType
,
typename
BasicJsonType
::
boolean_t
>::
value
,
!
std
::
is_same
<
ArithmeticType
,
typename
BasicJsonType
::
boolean_t
>::
value
,
int
>
=
0
>
int
>
=
0
>
void
get_arithmetic_value
(
const
BasicJsonType
&
j
,
ArithmeticType
&
val
)
void
get_arithmetic_value
(
const
BasicJsonType
&
j
,
ArithmeticType
&
val
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment