Skip to content

Commit

Permalink
Ignores the cppcheck warnings about missing explicit keywords on cons…
Browse files Browse the repository at this point in the history
…tructor with one parameter in json_ref.hpp.
  • Loading branch information
Xav83 committed Dec 20, 2019
1 parent edef01a commit 67b8c21
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/nlohmann/detail/json_ref.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,25 @@ class json_ref
public:
using value_type = BasicJsonType;

// cppcheck-suppress noExplicitConstructor
json_ref(value_type&& value)
: owned_value(std::move(value)), value_ref(&owned_value), is_rvalue(true)
{}

// cppcheck-suppress noExplicitConstructor
json_ref(const value_type& value)
: value_ref(const_cast<value_type*>(&value)), is_rvalue(false)
{}

// cppcheck-suppress noExplicitConstructor
json_ref(std::initializer_list<json_ref> init)
: owned_value(init), value_ref(&owned_value), is_rvalue(true)
{}

template <
class... Args,
enable_if_t<std::is_constructible<value_type, Args...>::value, int> = 0 >
// cppcheck-suppress noExplicitConstructor
json_ref(Args && ... args)
: owned_value(std::forward<Args>(args)...), value_ref(&owned_value),
is_rvalue(true) {}
Expand Down
4 changes: 4 additions & 0 deletions single_include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11103,21 +11103,25 @@ class json_ref
public:
using value_type = BasicJsonType;

// cppcheck-suppress noExplicitConstructor
json_ref(value_type&& value)
: owned_value(std::move(value)), value_ref(&owned_value), is_rvalue(true)
{}

// cppcheck-suppress noExplicitConstructor
json_ref(const value_type& value)
: value_ref(const_cast<value_type*>(&value)), is_rvalue(false)
{}

// cppcheck-suppress noExplicitConstructor
json_ref(std::initializer_list<json_ref> init)
: owned_value(init), value_ref(&owned_value), is_rvalue(true)
{}

template <
class... Args,
enable_if_t<std::is_constructible<value_type, Args...>::value, int> = 0 >
// cppcheck-suppress noExplicitConstructor
json_ref(Args && ... args)
: owned_value(std::forward<Args>(args)...), value_ref(&owned_value),
is_rvalue(true) {}
Expand Down

0 comments on commit 67b8c21

Please sign in to comment.