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 input_adapters.hpp.
  • Loading branch information
Xav83 committed Dec 20, 2019
1 parent 67b8c21 commit e8678d3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/nlohmann/detail/input/input_adapters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,22 +336,28 @@ class input_adapter
public:
// native support
JSON_HEDLEY_NON_NULL(2)
// cppcheck-suppress noExplicitConstructor
input_adapter(std::FILE* file)
: ia(std::make_shared<file_input_adapter>(file)) {}
/// input adapter for input stream
// cppcheck-suppress noExplicitConstructor
input_adapter(std::istream& i)
: ia(std::make_shared<input_stream_adapter>(i)) {}

/// input adapter for input stream
// cppcheck-suppress noExplicitConstructor
input_adapter(std::istream&& i)
: ia(std::make_shared<input_stream_adapter>(i)) {}

// cppcheck-suppress noExplicitConstructor
input_adapter(const std::wstring& ws)
: ia(std::make_shared<wide_string_input_adapter<std::wstring>>(ws)) {}

// cppcheck-suppress noExplicitConstructor
input_adapter(const std::u16string& ws)
: ia(std::make_shared<wide_string_input_adapter<std::u16string>>(ws)) {}

// cppcheck-suppress noExplicitConstructor
input_adapter(const std::u32string& ws)
: ia(std::make_shared<wide_string_input_adapter<std::u32string>>(ws)) {}

Expand All @@ -374,6 +380,7 @@ class input_adapter
std::is_integral<typename std::remove_pointer<CharT>::type>::value and
sizeof(typename std::remove_pointer<CharT>::type) == 1,
int>::type = 0>
// cppcheck-suppress noExplicitConstructor
input_adapter(CharT b)
: input_adapter(reinterpret_cast<const char*>(b),
std::strlen(reinterpret_cast<const char*>(b))) {}
Expand Down Expand Up @@ -418,6 +425,7 @@ class input_adapter

/// input adapter for array
template<class T, std::size_t N>
// cppcheck-suppress noExplicitConstructor
input_adapter(T (&array)[N])
: input_adapter(std::begin(array), std::end(array)) {}

Expand All @@ -426,6 +434,7 @@ class input_adapter
std::enable_if<not std::is_pointer<ContiguousContainer>::value and
std::is_base_of<std::random_access_iterator_tag, typename iterator_traits<decltype(std::begin(std::declval<ContiguousContainer const>()))>::iterator_category>::value,
int>::type = 0>
// cppcheck-suppress noExplicitConstructor
input_adapter(const ContiguousContainer& c)
: input_adapter(std::begin(c), std::end(c)) {}

Expand Down
9 changes: 9 additions & 0 deletions single_include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4199,22 +4199,28 @@ class input_adapter
public:
// native support
JSON_HEDLEY_NON_NULL(2)
// cppcheck-suppress noExplicitConstructor
input_adapter(std::FILE* file)
: ia(std::make_shared<file_input_adapter>(file)) {}
/// input adapter for input stream
// cppcheck-suppress noExplicitConstructor
input_adapter(std::istream& i)
: ia(std::make_shared<input_stream_adapter>(i)) {}

/// input adapter for input stream
// cppcheck-suppress noExplicitConstructor
input_adapter(std::istream&& i)
: ia(std::make_shared<input_stream_adapter>(i)) {}

// cppcheck-suppress noExplicitConstructor
input_adapter(const std::wstring& ws)
: ia(std::make_shared<wide_string_input_adapter<std::wstring>>(ws)) {}

// cppcheck-suppress noExplicitConstructor
input_adapter(const std::u16string& ws)
: ia(std::make_shared<wide_string_input_adapter<std::u16string>>(ws)) {}

// cppcheck-suppress noExplicitConstructor
input_adapter(const std::u32string& ws)
: ia(std::make_shared<wide_string_input_adapter<std::u32string>>(ws)) {}

Expand All @@ -4237,6 +4243,7 @@ class input_adapter
std::is_integral<typename std::remove_pointer<CharT>::type>::value and
sizeof(typename std::remove_pointer<CharT>::type) == 1,
int>::type = 0>
// cppcheck-suppress noExplicitConstructor
input_adapter(CharT b)
: input_adapter(reinterpret_cast<const char*>(b),
std::strlen(reinterpret_cast<const char*>(b))) {}
Expand Down Expand Up @@ -4281,6 +4288,7 @@ class input_adapter

/// input adapter for array
template<class T, std::size_t N>
// cppcheck-suppress noExplicitConstructor
input_adapter(T (&array)[N])
: input_adapter(std::begin(array), std::end(array)) {}

Expand All @@ -4289,6 +4297,7 @@ class input_adapter
std::enable_if<not std::is_pointer<ContiguousContainer>::value and
std::is_base_of<std::random_access_iterator_tag, typename iterator_traits<decltype(std::begin(std::declval<ContiguousContainer const>()))>::iterator_category>::value,
int>::type = 0>
// cppcheck-suppress noExplicitConstructor
input_adapter(const ContiguousContainer& c)
: input_adapter(std::begin(c), std::end(c)) {}

Expand Down

0 comments on commit e8678d3

Please sign in to comment.