Adapt code to review

This commit is contained in:
barcode 2022-07-05 09:52:44 +02:00
parent 5539e6f80c
commit 0a8e16d872
5 changed files with 9 additions and 8 deletions

View File

@ -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);
}
break;
case value_t::discarded:
break;
case value_t::null:
case value_t::string:
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_float:
case value_t::binary:
default:
fnc(ptr, j);
break;
case value_t::discarded:
default:
break;
}
}

View File

@ -21,7 +21,7 @@ The default value for `CustomBaseClass` is `void`. In this case an empty base cl
#### Limitations
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

View File

@ -1204,12 +1204,12 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
/// @brief move constructor
/// @sa https://json.nlohmann.me/api/basic_json/basic_json/
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_value(std::move(other.m_value))
{
// 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
other.m_type = value_t::null;

View File

@ -46,7 +46,7 @@ template<template<typename U, typename V, typename... Args> class ObjectType =
template<typename U> class AllocatorType = std::allocator,
template<typename T, typename SFINAE = void> class JSONSerializer =
adl_serializer,
class BinaryType = std::vector<std::uint8_t>, // cppcheck-suppress syntaxError
class BinaryType = std::vector<std::uint8_t>,
class CustomBaseClass = void>
class basic_json;

View File

@ -175,7 +175,7 @@ TEST_CASE("JSON Node Metadata")
{
using json = json_with_metadata<std::unique_ptr<int>>;
json value;
value.metadata().reset(new int(42)); // NOLINT
value.metadata().reset(new int(42)); // NOLINT(cppcoreguidelines-owning-memory)
auto moved = std::move(value);
CHECK(moved.metadata() != nullptr);