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
bdb2469c
Unverified
Commit
bdb2469c
authored
Dec 29, 2020
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🚨
fix warnings
parent
c8866467
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
65 deletions
+39
-65
Makefile
Makefile
+2
-0
input_adapters.hpp
include/nlohmann/detail/input/input_adapters.hpp
+7
-6
iter_impl.hpp
include/nlohmann/detail/iterators/iter_impl.hpp
+7
-26
json.hpp
single_include/nlohmann/json.hpp
+15
-33
unit-conversions.cpp
test/src/unit-conversions.cpp
+8
-0
No files found.
Makefile
View file @
bdb2469c
...
@@ -84,6 +84,7 @@ doctest:
...
@@ -84,6 +84,7 @@ doctest:
# -Wno-missing-prototypes: for NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE
# -Wno-missing-prototypes: for NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE
# -Wno-padded: padding is nothing to warn about
# -Wno-padded: padding is nothing to warn about
# -Wno-range-loop-analysis: items tests "for(const auto i...)"
# -Wno-range-loop-analysis: items tests "for(const auto i...)"
# -Wno-extra-semi-stmt: spurious warnings for semicolons after JSON_ASSERT()
# -Wno-switch-enum -Wno-covered-switch-default: pedantic/contradicting warnings about switches
# -Wno-switch-enum -Wno-covered-switch-default: pedantic/contradicting warnings about switches
# -Wno-weak-vtables: exception class is defined inline, but has virtual method
# -Wno-weak-vtables: exception class is defined inline, but has virtual method
pedantic_clang
:
pedantic_clang
:
...
@@ -100,6 +101,7 @@ pedantic_clang:
...
@@ -100,6 +101,7 @@ pedantic_clang:
-Wno-missing-prototypes
\
-Wno-missing-prototypes
\
-Wno-padded
\
-Wno-padded
\
-Wno-range-loop-analysis
\
-Wno-range-loop-analysis
\
-Wno-extra-semi-stmt
\
-Wno-switch-enum -Wno-covered-switch-default
\
-Wno-switch-enum -Wno-covered-switch-default
\
-Wno-weak-vtables"
cmake
-S
.
-B
cmake-build-pedantic
-GNinja
-DCMAKE_BUILD_TYPE
=
Debug
-DJSON_MultipleHeaders
=
ON
-DJSON_BuildTests
=
On
-Wno-weak-vtables"
cmake
-S
.
-B
cmake-build-pedantic
-GNinja
-DCMAKE_BUILD_TYPE
=
Debug
-DJSON_MultipleHeaders
=
ON
-DJSON_BuildTests
=
On
cmake
--build
cmake-build-pedantic
cmake
--build
cmake-build-pedantic
...
...
include/nlohmann/detail/input/input_adapters.hpp
View file @
bdb2469c
...
@@ -374,7 +374,8 @@ typename iterator_input_adapter_factory<IteratorType>::adapter_type input_adapte
...
@@ -374,7 +374,8 @@ typename iterator_input_adapter_factory<IteratorType>::adapter_type input_adapte
// Enables ADL on begin(container) and end(container)
// Enables ADL on begin(container) and end(container)
// Encloses the using declarations in namespace for not to leak them to outside scope
// Encloses the using declarations in namespace for not to leak them to outside scope
namespace
container_input_adapter_factory_impl
{
namespace
container_input_adapter_factory_impl
{
using
std
::
begin
;
using
std
::
begin
;
using
std
::
end
;
using
std
::
end
;
...
@@ -384,15 +385,15 @@ struct container_input_adapter_factory {};
...
@@ -384,15 +385,15 @@ struct container_input_adapter_factory {};
template
<
typename
ContainerType
>
template
<
typename
ContainerType
>
struct
container_input_adapter_factory
<
ContainerType
,
struct
container_input_adapter_factory
<
ContainerType
,
void_t
<
decltype
(
begin
(
std
::
declval
<
ContainerType
>
()),
end
(
std
::
declval
<
ContainerType
>
()))
>
>
void_t
<
decltype
(
begin
(
std
::
declval
<
ContainerType
>
()),
end
(
std
::
declval
<
ContainerType
>
()))
>
>
{
{
using
adapter_type
=
decltype
(
input_adapter
(
begin
(
std
::
declval
<
ContainerType
>
()),
end
(
std
::
declval
<
ContainerType
>
())));
using
adapter_type
=
decltype
(
input_adapter
(
begin
(
std
::
declval
<
ContainerType
>
()),
end
(
std
::
declval
<
ContainerType
>
())));
static
adapter_type
create
(
const
ContainerType
&
container
)
static
adapter_type
create
(
const
ContainerType
&
container
)
{
{
return
input_adapter
(
begin
(
container
),
end
(
container
));
return
input_adapter
(
begin
(
container
),
end
(
container
));
}
}
};
};
}
}
...
...
include/nlohmann/detail/iterators/iter_impl.hpp
View file @
bdb2469c
...
@@ -38,8 +38,10 @@ This class implements a both iterators (iterator and const_iterator) for the
...
@@ -38,8 +38,10 @@ This class implements a both iterators (iterator and const_iterator) for the
template
<
typename
BasicJsonType
>
template
<
typename
BasicJsonType
>
class
iter_impl
class
iter_impl
{
{
/// the iterator with BasicJsonType of different const-ness
using
other_iter_impl
=
iter_impl
<
typename
std
::
conditional
<
std
::
is_const
<
BasicJsonType
>::
value
,
typename
std
::
remove_const
<
BasicJsonType
>::
type
,
const
BasicJsonType
>::
type
>
;
/// allow basic_json to access private members
/// allow basic_json to access private members
friend
iter_impl
<
typename
std
::
conditional
<
std
::
is_const
<
BasicJsonType
>::
value
,
typename
std
::
remove_const
<
BasicJsonType
>::
type
,
const
BasicJsonType
>::
type
>
;
friend
other_iter_impl
;
friend
BasicJsonType
;
friend
BasicJsonType
;
friend
iteration_proxy
<
iter_impl
>
;
friend
iteration_proxy
<
iter_impl
>
;
friend
iteration_proxy_value
<
iter_impl
>
;
friend
iteration_proxy_value
<
iter_impl
>
;
...
@@ -393,30 +395,8 @@ class iter_impl
...
@@ -393,30 +395,8 @@ class iter_impl
@brief comparison: equal
@brief comparison: equal
@pre The iterator is initialized; i.e. `m_object != nullptr`.
@pre The iterator is initialized; i.e. `m_object != nullptr`.
*/
*/
bool
operator
==
(
const
iter_impl
<
const
BasicJsonType
>&
other
)
const
template
<
typename
IterImpl
,
detail
::
enable_if_t
<
(
std
::
is_same
<
IterImpl
,
iter_impl
>::
value
||
std
::
is_same
<
IterImpl
,
other_iter_impl
>::
value
),
std
::
nullptr_t
>
=
nullptr
>
{
bool
operator
==
(
const
IterImpl
&
other
)
const
// if objects are not the same, the comparison is undefined
if
(
JSON_HEDLEY_UNLIKELY
(
m_object
!=
other
.
m_object
))
{
JSON_THROW
(
invalid_iterator
::
create
(
212
,
"cannot compare iterators of different containers"
));
}
JSON_ASSERT
(
m_object
!=
nullptr
);
switch
(
m_object
->
m_type
)
{
case
value_t
:
:
object
:
return
(
m_it
.
object_iterator
==
other
.
m_it
.
object_iterator
);
case
value_t
:
:
array
:
return
(
m_it
.
array_iterator
==
other
.
m_it
.
array_iterator
);
default
:
return
(
m_it
.
primitive_iterator
==
other
.
m_it
.
primitive_iterator
);
}
}
bool
operator
==
(
const
iter_impl
<
typename
std
::
remove_const
<
BasicJsonType
>::
type
>&
other
)
const
{
{
// if objects are not the same, the comparison is undefined
// if objects are not the same, the comparison is undefined
if
(
JSON_HEDLEY_UNLIKELY
(
m_object
!=
other
.
m_object
))
if
(
JSON_HEDLEY_UNLIKELY
(
m_object
!=
other
.
m_object
))
...
@@ -443,7 +423,8 @@ class iter_impl
...
@@ -443,7 +423,8 @@ class iter_impl
@brief comparison: not equal
@brief comparison: not equal
@pre The iterator is initialized; i.e. `m_object != nullptr`.
@pre The iterator is initialized; i.e. `m_object != nullptr`.
*/
*/
bool
operator
!=
(
const
iter_impl
&
other
)
const
template
<
typename
IterImpl
,
detail
::
enable_if_t
<
(
std
::
is_same
<
IterImpl
,
iter_impl
>::
value
||
std
::
is_same
<
IterImpl
,
other_iter_impl
>::
value
),
std
::
nullptr_t
>
=
nullptr
>
bool
operator
!=
(
const
IterImpl
&
other
)
const
{
{
return
!
operator
==
(
other
);
return
!
operator
==
(
other
);
}
}
...
...
single_include/nlohmann/json.hpp
View file @
bdb2469c
...
@@ -5186,7 +5186,8 @@ typename iterator_input_adapter_factory<IteratorType>::adapter_type input_adapte
...
@@ -5186,7 +5186,8 @@ typename iterator_input_adapter_factory<IteratorType>::adapter_type input_adapte
// Enables ADL on begin(container) and end(container)
// Enables ADL on begin(container) and end(container)
// Encloses the using declarations in namespace for not to leak them to outside scope
// Encloses the using declarations in namespace for not to leak them to outside scope
namespace
container_input_adapter_factory_impl
{
namespace
container_input_adapter_factory_impl
{
using
std
::
begin
;
using
std
::
begin
;
using
std
::
end
;
using
std
::
end
;
...
@@ -5196,15 +5197,15 @@ struct container_input_adapter_factory {};
...
@@ -5196,15 +5197,15 @@ struct container_input_adapter_factory {};
template
<
typename
ContainerType
>
template
<
typename
ContainerType
>
struct
container_input_adapter_factory
<
ContainerType
,
struct
container_input_adapter_factory
<
ContainerType
,
void_t
<
decltype
(
begin
(
std
::
declval
<
ContainerType
>
()),
end
(
std
::
declval
<
ContainerType
>
()))
>
>
void_t
<
decltype
(
begin
(
std
::
declval
<
ContainerType
>
()),
end
(
std
::
declval
<
ContainerType
>
()))
>
>
{
{
using
adapter_type
=
decltype
(
input_adapter
(
begin
(
std
::
declval
<
ContainerType
>
()),
end
(
std
::
declval
<
ContainerType
>
())));
using
adapter_type
=
decltype
(
input_adapter
(
begin
(
std
::
declval
<
ContainerType
>
()),
end
(
std
::
declval
<
ContainerType
>
())));
static
adapter_type
create
(
const
ContainerType
&
container
)
static
adapter_type
create
(
const
ContainerType
&
container
)
{
{
return
input_adapter
(
begin
(
container
),
end
(
container
));
return
input_adapter
(
begin
(
container
),
end
(
container
));
}
}
};
};
}
}
...
@@ -10924,8 +10925,10 @@ This class implements a both iterators (iterator and const_iterator) for the
...
@@ -10924,8 +10925,10 @@ This class implements a both iterators (iterator and const_iterator) for the
template
<
typename
BasicJsonType
>
template
<
typename
BasicJsonType
>
class
iter_impl
class
iter_impl
{
{
/// the iterator with BasicJsonType of different const-ness
using
other_iter_impl
=
iter_impl
<
typename
std
::
conditional
<
std
::
is_const
<
BasicJsonType
>::
value
,
typename
std
::
remove_const
<
BasicJsonType
>::
type
,
const
BasicJsonType
>::
type
>
;
/// allow basic_json to access private members
/// allow basic_json to access private members
friend
iter_impl
<
typename
std
::
conditional
<
std
::
is_const
<
BasicJsonType
>::
value
,
typename
std
::
remove_const
<
BasicJsonType
>::
type
,
const
BasicJsonType
>::
type
>
;
friend
other_iter_impl
;
friend
BasicJsonType
;
friend
BasicJsonType
;
friend
iteration_proxy
<
iter_impl
>
;
friend
iteration_proxy
<
iter_impl
>
;
friend
iteration_proxy_value
<
iter_impl
>
;
friend
iteration_proxy_value
<
iter_impl
>
;
...
@@ -11279,30 +11282,8 @@ class iter_impl
...
@@ -11279,30 +11282,8 @@ class iter_impl
@brief comparison: equal
@brief comparison: equal
@pre The iterator is initialized; i.e. `m_object != nullptr`.
@pre The iterator is initialized; i.e. `m_object != nullptr`.
*/
*/
bool
operator
==
(
const
iter_impl
<
const
BasicJsonType
>&
other
)
const
template
<
typename
IterImpl
,
detail
::
enable_if_t
<
(
std
::
is_same
<
IterImpl
,
iter_impl
>::
value
||
std
::
is_same
<
IterImpl
,
other_iter_impl
>::
value
),
std
::
nullptr_t
>
=
nullptr
>
{
bool
operator
==
(
const
IterImpl
&
other
)
const
// if objects are not the same, the comparison is undefined
if
(
JSON_HEDLEY_UNLIKELY
(
m_object
!=
other
.
m_object
))
{
JSON_THROW
(
invalid_iterator
::
create
(
212
,
"cannot compare iterators of different containers"
));
}
JSON_ASSERT
(
m_object
!=
nullptr
);
switch
(
m_object
->
m_type
)
{
case
value_t
:
:
object
:
return
(
m_it
.
object_iterator
==
other
.
m_it
.
object_iterator
);
case
value_t
:
:
array
:
return
(
m_it
.
array_iterator
==
other
.
m_it
.
array_iterator
);
default
:
return
(
m_it
.
primitive_iterator
==
other
.
m_it
.
primitive_iterator
);
}
}
bool
operator
==
(
const
iter_impl
<
typename
std
::
remove_const
<
BasicJsonType
>::
type
>&
other
)
const
{
{
// if objects are not the same, the comparison is undefined
// if objects are not the same, the comparison is undefined
if
(
JSON_HEDLEY_UNLIKELY
(
m_object
!=
other
.
m_object
))
if
(
JSON_HEDLEY_UNLIKELY
(
m_object
!=
other
.
m_object
))
...
@@ -11329,7 +11310,8 @@ class iter_impl
...
@@ -11329,7 +11310,8 @@ class iter_impl
@brief comparison: not equal
@brief comparison: not equal
@pre The iterator is initialized; i.e. `m_object != nullptr`.
@pre The iterator is initialized; i.e. `m_object != nullptr`.
*/
*/
bool
operator
!=
(
const
iter_impl
&
other
)
const
template
<
typename
IterImpl
,
detail
::
enable_if_t
<
(
std
::
is_same
<
IterImpl
,
iter_impl
>::
value
||
std
::
is_same
<
IterImpl
,
other_iter_impl
>::
value
),
std
::
nullptr_t
>
=
nullptr
>
bool
operator
!=
(
const
IterImpl
&
other
)
const
{
{
return
!
operator
==
(
other
);
return
!
operator
==
(
other
);
}
}
...
@@ -25390,7 +25372,7 @@ template<>
...
@@ -25390,7 +25372,7 @@ template<>
inline
void
swap
<
nlohmann
::
json
>
(
nlohmann
::
json
&
j1
,
nlohmann
::
json
&
j2
)
noexcept
(
inline
void
swap
<
nlohmann
::
json
>
(
nlohmann
::
json
&
j1
,
nlohmann
::
json
&
j2
)
noexcept
(
is_nothrow_move_constructible
<
nlohmann
::
json
>::
value
&&
is_nothrow_move_constructible
<
nlohmann
::
json
>::
value
&&
is_nothrow_move_assignable
<
nlohmann
::
json
>::
value
is_nothrow_move_assignable
<
nlohmann
::
json
>::
value
)
)
{
{
j1
.
swap
(
j2
);
j1
.
swap
(
j2
);
}
}
...
...
test/src/unit-conversions.cpp
View file @
bdb2469c
...
@@ -1702,3 +1702,11 @@ TEST_CASE("JSON to enum mapping")
...
@@ -1702,3 +1702,11 @@ TEST_CASE("JSON to enum mapping")
CHECK
(
TS_INVALID
==
json
(
"what?"
).
get
<
TaskState
>
());
CHECK
(
TS_INVALID
==
json
(
"what?"
).
get
<
TaskState
>
());
}
}
}
}
#ifdef JSON_HAS_CPP_17
#undef JSON_HAS_CPP_17
#endif
#ifdef JSON_HAS_CPP_14
#undef JSON_HAS_CPP_14
#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