Adapt code to review
This commit is contained in:
parent
5539e6f80c
commit
0a8e16d872
@ -54,8 +54,6 @@ void visitor_adaptor_with_metadata::do_visit(const Ptr& ptr, const Fnc& fnc) con
|
|||||||
j.at(i).do_visit(ptr / std::to_string(i), fnc);
|
j.at(i).do_visit(ptr / std::to_string(i), fnc);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case value_t::discarded:
|
|
||||||
break;
|
|
||||||
case value_t::null:
|
case value_t::null:
|
||||||
case value_t::string:
|
case value_t::string:
|
||||||
case value_t::boolean:
|
case value_t::boolean:
|
||||||
@ -63,8 +61,11 @@ void visitor_adaptor_with_metadata::do_visit(const Ptr& ptr, const Fnc& fnc) con
|
|||||||
case value_t::number_unsigned:
|
case value_t::number_unsigned:
|
||||||
case value_t::number_float:
|
case value_t::number_float:
|
||||||
case value_t::binary:
|
case value_t::binary:
|
||||||
default:
|
|
||||||
fnc(ptr, j);
|
fnc(ptr, j);
|
||||||
|
break;
|
||||||
|
case value_t::discarded:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,7 @@ The default value for `CustomBaseClass` is `void`. In this case an empty base cl
|
|||||||
#### Limitations
|
#### Limitations
|
||||||
|
|
||||||
The type `CustomBaseClass` has to be a default constructible class.
|
The type `CustomBaseClass` has to be a default constructible class.
|
||||||
`basic_json` only supports copy/move construction/assignement if `CustomBaseClass` does so as well.
|
`basic_json` only supports copy/move construction/assignment if `CustomBaseClass` does so as well.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
|||||||
@ -1204,12 +1204,12 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
/// @brief move constructor
|
/// @brief move constructor
|
||||||
/// @sa https://json.nlohmann.me/api/basic_json/basic_json/
|
/// @sa https://json.nlohmann.me/api/basic_json/basic_json/
|
||||||
basic_json(basic_json&& other) noexcept
|
basic_json(basic_json&& other) noexcept
|
||||||
: json_base_class_t(static_cast < json_base_class_t&& > (other)),
|
: json_base_class_t(std::move(other)),
|
||||||
m_type(std::move(other.m_type)),
|
m_type(std::move(other.m_type)),
|
||||||
m_value(std::move(other.m_value))
|
m_value(std::move(other.m_value))
|
||||||
{
|
{
|
||||||
// check that passed value is valid
|
// check that passed value is valid
|
||||||
other.assert_invariant(false);
|
other.assert_invariant(false); // NOLINT(bugprone-use-after-move,hicpp-invalid-access-moved)
|
||||||
|
|
||||||
// invalidate payload
|
// invalidate payload
|
||||||
other.m_type = value_t::null;
|
other.m_type = value_t::null;
|
||||||
|
|||||||
@ -46,7 +46,7 @@ template<template<typename U, typename V, typename... Args> class ObjectType =
|
|||||||
template<typename U> class AllocatorType = std::allocator,
|
template<typename U> class AllocatorType = std::allocator,
|
||||||
template<typename T, typename SFINAE = void> class JSONSerializer =
|
template<typename T, typename SFINAE = void> class JSONSerializer =
|
||||||
adl_serializer,
|
adl_serializer,
|
||||||
class BinaryType = std::vector<std::uint8_t>, // cppcheck-suppress syntaxError
|
class BinaryType = std::vector<std::uint8_t>,
|
||||||
class CustomBaseClass = void>
|
class CustomBaseClass = void>
|
||||||
class basic_json;
|
class basic_json;
|
||||||
|
|
||||||
|
|||||||
@ -175,7 +175,7 @@ TEST_CASE("JSON Node Metadata")
|
|||||||
{
|
{
|
||||||
using json = json_with_metadata<std::unique_ptr<int>>;
|
using json = json_with_metadata<std::unique_ptr<int>>;
|
||||||
json value;
|
json value;
|
||||||
value.metadata().reset(new int(42)); // NOLINT
|
value.metadata().reset(new int(42)); // NOLINT(cppcoreguidelines-owning-memory)
|
||||||
auto moved = std::move(value);
|
auto moved = std::move(value);
|
||||||
|
|
||||||
CHECK(moved.metadata() != nullptr);
|
CHECK(moved.metadata() != nullptr);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user