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
0f1f5052
Unverified
Commit
0f1f5052
authored
Jul 13, 2020
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
💚
add trait for 128 bit integers
parent
e3aace6d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
15 deletions
+25
-15
Makefile
Makefile
+3
-3
type_traits.hpp
include/nlohmann/detail/meta/type_traits.hpp
+11
-0
json.hpp
single_include/nlohmann/json.hpp
+11
-0
unit-alt-number.cpp
test/src/unit-alt-number.cpp
+0
-12
No files found.
Makefile
View file @
0f1f5052
...
@@ -468,7 +468,7 @@ cppcheck:
...
@@ -468,7 +468,7 @@ cppcheck:
clang_analyze
:
clang_analyze
:
rm
-fr
clang_analyze_build
rm
-fr
clang_analyze_build
mkdir
clang_analyze_build
mkdir
clang_analyze_build
cd
clang_analyze_build
;
CCC_CXX
=
$(COMPILER_DIR)
/clang++
CXX
=
$(COMPILER_DIR)
/clang++
$(COMPILER_DIR)
/scan-build cmake ..
-GNinja
-DJSON_BuildTests
=
On
cd
clang_analyze_build
;
CCC_CXX
=
$(COMPILER_DIR)
/clang++
CXX
=
$(COMPILER_DIR)
/clang++
$(COMPILER_DIR)
/scan-build cmake ..
-GNinja
-DJSON_BuildTests
=
On
-DJSON_MultipleHeaders
=
On
cd
clang_analyze_build
;
\
cd
clang_analyze_build
;
\
$(COMPILER_DIR)
/scan-build
\
$(COMPILER_DIR)
/scan-build
\
-enable-checker
alpha.core.BoolAssignment,alpha.core.CallAndMessageUnInitRefArg,alpha.core.CastSize,alpha.core.CastToStruct,alpha.core.Conversion,alpha.core.DynamicTypeChecker,alpha.core.FixedAddr,alpha.core.PointerArithm,alpha.core.PointerSub,alpha.core.SizeofPtr,alpha.core.StackAddressAsyncEscape,alpha.core.TestAfterDivZero,alpha.deadcode.UnreachableCode,core.builtin.BuiltinFunctions,core.builtin.NoReturnFunctions,core.CallAndMessage,core.DivideZero,core.DynamicTypePropagation,core.NonnilStringConstants,core.NonNullParamChecker,core.NullDereference,core.StackAddressEscape,core.UndefinedBinaryOperatorResult,core.uninitialized.ArraySubscript,core.uninitialized.Assign,core.uninitialized.Branch,core.uninitialized.CapturedBlockVariable,core.uninitialized.UndefReturn,core.VLASize,cplusplus.InnerPointer,cplusplus.Move,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,cplusplus.SelfAssignment,deadcode.DeadStores,nullability.NullableDereferenced,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull
\
-enable-checker
alpha.core.BoolAssignment,alpha.core.CallAndMessageUnInitRefArg,alpha.core.CastSize,alpha.core.CastToStruct,alpha.core.Conversion,alpha.core.DynamicTypeChecker,alpha.core.FixedAddr,alpha.core.PointerArithm,alpha.core.PointerSub,alpha.core.SizeofPtr,alpha.core.StackAddressAsyncEscape,alpha.core.TestAfterDivZero,alpha.deadcode.UnreachableCode,core.builtin.BuiltinFunctions,core.builtin.NoReturnFunctions,core.CallAndMessage,core.DivideZero,core.DynamicTypePropagation,core.NonnilStringConstants,core.NonNullParamChecker,core.NullDereference,core.StackAddressEscape,core.UndefinedBinaryOperatorResult,core.uninitialized.ArraySubscript,core.uninitialized.Assign,core.uninitialized.Branch,core.uninitialized.CapturedBlockVariable,core.uninitialized.UndefReturn,core.VLASize,cplusplus.InnerPointer,cplusplus.Move,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,cplusplus.SelfAssignment,deadcode.DeadStores,nullability.NullableDereferenced,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull
\
...
@@ -490,7 +490,7 @@ clang_tidy:
...
@@ -490,7 +490,7 @@ clang_tidy:
pvs_studio
:
pvs_studio
:
rm
-fr
pvs_studio_build
rm
-fr
pvs_studio_build
mkdir
pvs_studio_build
mkdir
pvs_studio_build
cd
pvs_studio_build
;
cmake ..
-DCMAKE_EXPORT_COMPILE_COMMANDS
=
On
cd
pvs_studio_build
;
cmake ..
-DCMAKE_EXPORT_COMPILE_COMMANDS
=
On
-DJSON_MultipleHeaders
=
On
cd
pvs_studio_build
;
pvs-studio-analyzer analyze
-j
10
cd
pvs_studio_build
;
pvs-studio-analyzer analyze
-j
10
cd
pvs_studio_build
;
plog-converter
-a
'GA:1,2;64:1;CS'
-t
fullhtml PVS-Studio.log
-o
pvs
cd
pvs_studio_build
;
plog-converter
-a
'GA:1,2;64:1;CS'
-t
fullhtml PVS-Studio.log
-o
pvs
open pvs_studio_build/pvs/index.html
open pvs_studio_build/pvs/index.html
...
@@ -499,7 +499,7 @@ pvs_studio:
...
@@ -499,7 +499,7 @@ pvs_studio:
infer
:
infer
:
rm
-fr
infer_build
rm
-fr
infer_build
mkdir
infer_build
mkdir
infer_build
cd
infer_build
;
infer compile
--
cmake ..
;
infer run
--
make
-j
4
cd
infer_build
;
infer compile
--
cmake ..
-DJSON_MultipleHeaders
=
On
;
infer run
--
make
-j
4
# call OCLint <http://oclint.org> static analyzer
# call OCLint <http://oclint.org> static analyzer
oclint
:
oclint
:
...
...
include/nlohmann/detail/meta/type_traits.hpp
View file @
0f1f5052
...
@@ -353,6 +353,17 @@ struct is_compatible_integer_type_impl <
...
@@ -353,6 +353,17 @@ struct is_compatible_integer_type_impl <
RealLimits
::
is_signed
==
CompatibleLimits
::
is_signed
;
RealLimits
::
is_signed
==
CompatibleLimits
::
is_signed
;
};
};
// second version for 128 bit integers that fail std::is_integral test
template
<
typename
RealIntegerType
,
typename
CompatibleNumberIntegerType
>
struct
is_compatible_integer_type_impl
<
RealIntegerType
,
CompatibleNumberIntegerType
,
enable_if_t
<
std
::
is_same
<
RealIntegerType
,
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_64_bit
<
RealIntegerType
>::
value
>>
{
static
constexpr
auto
value
=
true
;
};
template
<
typename
RealIntegerType
,
typename
CompatibleNumberIntegerType
>
template
<
typename
RealIntegerType
,
typename
CompatibleNumberIntegerType
>
struct
is_compatible_integer_type
struct
is_compatible_integer_type
:
is_compatible_integer_type_impl
<
RealIntegerType
,
:
is_compatible_integer_type_impl
<
RealIntegerType
,
...
...
single_include/nlohmann/json.hpp
View file @
0f1f5052
...
@@ -3168,6 +3168,17 @@ struct is_compatible_integer_type_impl <
...
@@ -3168,6 +3168,17 @@ struct is_compatible_integer_type_impl <
RealLimits
::
is_signed
==
CompatibleLimits
::
is_signed
;
RealLimits
::
is_signed
==
CompatibleLimits
::
is_signed
;
};
};
// second version for 128 bit integers that fail std::is_integral test
template
<
typename
RealIntegerType
,
typename
CompatibleNumberIntegerType
>
struct
is_compatible_integer_type_impl
<
RealIntegerType
,
CompatibleNumberIntegerType
,
enable_if_t
<
std
::
is_same
<
RealIntegerType
,
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_64_bit
<
RealIntegerType
>::
value
>>
{
static
constexpr
auto
value
=
true
;
};
template
<
typename
RealIntegerType
,
typename
CompatibleNumberIntegerType
>
template
<
typename
RealIntegerType
,
typename
CompatibleNumberIntegerType
>
struct
is_compatible_integer_type
struct
is_compatible_integer_type
:
is_compatible_integer_type_impl
<
RealIntegerType
,
:
is_compatible_integer_type_impl
<
RealIntegerType
,
...
...
test/src/unit-alt-number.cpp
View file @
0f1f5052
...
@@ -101,17 +101,6 @@ TEST_CASE("Alternative number types")
...
@@ -101,17 +101,6 @@ TEST_CASE("Alternative number types")
// 128-bit arithmetic does not work with sanitizers
// 128-bit arithmetic does not work with sanitizers
#if defined(__SIZEOF_INT128__) && !defined(__SANITIZE_ADDRESS__)
#if defined(__SIZEOF_INT128__) && !defined(__SANITIZE_ADDRESS__)
SECTION
(
"type traits"
)
{
CHECK
(
std
::
is_integral
<
__int128_t
>::
value
);
CHECK
(
std
::
is_integral
<
__uint128_t
>::
value
);
CHECK
(
std
::
numeric_limits
<
__int128_t
>::
is_integer
);
CHECK
(
std
::
numeric_limits
<
__uint128_t
>::
is_integer
);
CHECK
(
std
::
is_convertible
<
std
::
int64_t
,
__int128_t
>::
value
);
CHECK
(
std
::
is_convertible
<
std
::
uint64_t
,
__uint128_t
>::
value
);
}
/*
SECTION
(
"128 bit integers"
)
SECTION
(
"128 bit integers"
)
{
{
using
json128
=
nlohmann
::
basic_json
<
std
::
map
,
std
::
vector
,
std
::
string
,
bool
,
__int128_t
,
__uint128_t
>
;
using
json128
=
nlohmann
::
basic_json
<
std
::
map
,
std
::
vector
,
std
::
string
,
bool
,
__int128_t
,
__uint128_t
>
;
...
@@ -136,6 +125,5 @@ TEST_CASE("Alternative number types")
...
@@ -136,6 +125,5 @@ TEST_CASE("Alternative number types")
CHECK
(
json128
::
parse
(
j_signed_min
.
dump
())
==
j_signed_min
);
CHECK
(
json128
::
parse
(
j_signed_min
.
dump
())
==
j_signed_min
);
}
}
}
}
*/
#endif
#endif
}
}
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