🚨 fixed warnings

This commit is contained in:
Niels Lohmann 2019-03-17 12:01:49 +01:00
parent d6c4cd3b6d
commit b8451c236f
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69
19 changed files with 4721 additions and 4622 deletions

View file

@ -10,10 +10,10 @@
#include <valarray> // valarray #include <valarray> // valarray
#include <vector> // vector #include <vector> // vector
#include <nlohmann/detail/iterators/iteration_proxy.hpp>
#include <nlohmann/detail/meta/cpp_future.hpp> #include <nlohmann/detail/meta/cpp_future.hpp>
#include <nlohmann/detail/meta/type_traits.hpp> #include <nlohmann/detail/meta/type_traits.hpp>
#include <nlohmann/detail/value_t.hpp> #include <nlohmann/detail/value_t.hpp>
#include <nlohmann/detail/iterators/iteration_proxy.hpp>
namespace nlohmann namespace nlohmann
{ {

View file

@ -102,12 +102,12 @@ json.exception.parse_error.114 | parse error: Unsupported BSON record type 0x0F
@liveexample{The following code shows how a `parse_error` exception can be @liveexample{The following code shows how a `parse_error` exception can be
caught.,parse_error} caught.,parse_error}
@sa @ref exception for the base class of the library exceptions @sa - @ref exception for the base class of the library exceptions
@sa @ref invalid_iterator for exceptions indicating errors with iterators @sa - @ref invalid_iterator for exceptions indicating errors with iterators
@sa @ref type_error for exceptions indicating executing a member function with @sa - @ref type_error for exceptions indicating executing a member function with
a wrong type a wrong type
@sa @ref out_of_range for exceptions indicating access out of the defined range @sa - @ref out_of_range for exceptions indicating access out of the defined range
@sa @ref other_error for exceptions indicating other library errors @sa - @ref other_error for exceptions indicating other library errors
@since version 3.0.0 @since version 3.0.0
*/ */
@ -117,7 +117,7 @@ class parse_error : public exception
/*! /*!
@brief create a parse error exception @brief create a parse error exception
@param[in] id_ the id of the exception @param[in] id_ the id of the exception
@param[in] position the position where the error occurred (or with @param[in] pos the position where the error occurred (or with
chars_read_total=0 if the position cannot be chars_read_total=0 if the position cannot be
determined) determined)
@param[in] what_arg the explanatory string @param[in] what_arg the explanatory string
@ -188,12 +188,12 @@ json.exception.invalid_iterator.214 | cannot get value | Cannot get value for it
@liveexample{The following code shows how an `invalid_iterator` exception can be @liveexample{The following code shows how an `invalid_iterator` exception can be
caught.,invalid_iterator} caught.,invalid_iterator}
@sa @ref exception for the base class of the library exceptions @sa - @ref exception for the base class of the library exceptions
@sa @ref parse_error for exceptions indicating a parse error @sa - @ref parse_error for exceptions indicating a parse error
@sa @ref type_error for exceptions indicating executing a member function with @sa - @ref type_error for exceptions indicating executing a member function with
a wrong type a wrong type
@sa @ref out_of_range for exceptions indicating access out of the defined range @sa - @ref out_of_range for exceptions indicating access out of the defined range
@sa @ref other_error for exceptions indicating other library errors @sa - @ref other_error for exceptions indicating other library errors
@since version 3.0.0 @since version 3.0.0
*/ */
@ -242,11 +242,11 @@ json.exception.type_error.317 | JSON value cannot be serialized to requested for
@liveexample{The following code shows how a `type_error` exception can be @liveexample{The following code shows how a `type_error` exception can be
caught.,type_error} caught.,type_error}
@sa @ref exception for the base class of the library exceptions @sa - @ref exception for the base class of the library exceptions
@sa @ref parse_error for exceptions indicating a parse error @sa - @ref parse_error for exceptions indicating a parse error
@sa @ref invalid_iterator for exceptions indicating errors with iterators @sa - @ref invalid_iterator for exceptions indicating errors with iterators
@sa @ref out_of_range for exceptions indicating access out of the defined range @sa - @ref out_of_range for exceptions indicating access out of the defined range
@sa @ref other_error for exceptions indicating other library errors @sa - @ref other_error for exceptions indicating other library errors
@since version 3.0.0 @since version 3.0.0
*/ */
@ -287,12 +287,12 @@ json.exception.out_of_range.409 | BSON key cannot contain code point U+0000 (at
@liveexample{The following code shows how an `out_of_range` exception can be @liveexample{The following code shows how an `out_of_range` exception can be
caught.,out_of_range} caught.,out_of_range}
@sa @ref exception for the base class of the library exceptions @sa - @ref exception for the base class of the library exceptions
@sa @ref parse_error for exceptions indicating a parse error @sa - @ref parse_error for exceptions indicating a parse error
@sa @ref invalid_iterator for exceptions indicating errors with iterators @sa - @ref invalid_iterator for exceptions indicating errors with iterators
@sa @ref type_error for exceptions indicating executing a member function with @sa - @ref type_error for exceptions indicating executing a member function with
a wrong type a wrong type
@sa @ref other_error for exceptions indicating other library errors @sa - @ref other_error for exceptions indicating other library errors
@since version 3.0.0 @since version 3.0.0
*/ */
@ -321,12 +321,12 @@ name / id | example message | description
------------------------------ | --------------- | ------------------------- ------------------------------ | --------------- | -------------------------
json.exception.other_error.501 | unsuccessful: {"op":"test","path":"/baz", "value":"bar"} | A JSON Patch operation 'test' failed. The unsuccessful operation is also printed. json.exception.other_error.501 | unsuccessful: {"op":"test","path":"/baz", "value":"bar"} | A JSON Patch operation 'test' failed. The unsuccessful operation is also printed.
@sa @ref exception for the base class of the library exceptions @sa - @ref exception for the base class of the library exceptions
@sa @ref parse_error for exceptions indicating a parse error @sa - @ref parse_error for exceptions indicating a parse error
@sa @ref invalid_iterator for exceptions indicating errors with iterators @sa - @ref invalid_iterator for exceptions indicating errors with iterators
@sa @ref type_error for exceptions indicating executing a member function with @sa - @ref type_error for exceptions indicating executing a member function with
a wrong type a wrong type
@sa @ref out_of_range for exceptions indicating access out of the defined range @sa - @ref out_of_range for exceptions indicating access out of the defined range
@liveexample{The following code shows how an `other_error` exception can be @liveexample{The following code shows how an `other_error` exception can be
caught.,other_error} caught.,other_error}

View file

@ -13,9 +13,9 @@
#include <string> // char_traits, string #include <string> // char_traits, string
#include <utility> // make_pair, move #include <utility> // make_pair, move
#include <nlohmann/detail/exceptions.hpp>
#include <nlohmann/detail/input/input_adapters.hpp> #include <nlohmann/detail/input/input_adapters.hpp>
#include <nlohmann/detail/input/json_sax.hpp> #include <nlohmann/detail/input/json_sax.hpp>
#include <nlohmann/detail/exceptions.hpp>
#include <nlohmann/detail/macro_scope.hpp> #include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/meta/is_sax.hpp> #include <nlohmann/detail/meta/is_sax.hpp>
#include <nlohmann/detail/value_t.hpp> #include <nlohmann/detail/value_t.hpp>
@ -52,6 +52,13 @@ class binary_reader
assert(ia); assert(ia);
} }
// make class move-only
binary_reader(const binary_reader&) = delete;
binary_reader(binary_reader&&) noexcept = default;
binary_reader& operator=(const binary_reader&) = delete;
binary_reader& operator=(binary_reader&&) noexcept = default;
~binary_reader() = default;
/*! /*!
@param[in] format the binary format to parse @param[in] format the binary format to parse
@param[in] sax_ a SAX event processor @param[in] sax_ a SAX event processor

View file

@ -3,6 +3,7 @@
#include <array> // array #include <array> // array
#include <cassert> // assert #include <cassert> // assert
#include <cstddef> // size_t #include <cstddef> // size_t
#include <cstdio> //FILE *
#include <cstring> // strlen #include <cstring> // strlen
#include <istream> // istream #include <istream> // istream
#include <iterator> // begin, end, iterator_traits, random_access_iterator_tag, distance, next #include <iterator> // begin, end, iterator_traits, random_access_iterator_tag, distance, next
@ -11,7 +12,6 @@
#include <string> // string, char_traits #include <string> // string, char_traits
#include <type_traits> // enable_if, is_base_of, is_pointer, is_integral, remove_pointer #include <type_traits> // enable_if, is_base_of, is_pointer, is_integral, remove_pointer
#include <utility> // pair, declval #include <utility> // pair, declval
#include <cstdio> //FILE *
#include <nlohmann/detail/iterators/iterator_traits.hpp> #include <nlohmann/detail/iterators/iterator_traits.hpp>
#include <nlohmann/detail/macro_scope.hpp> #include <nlohmann/detail/macro_scope.hpp>
@ -59,10 +59,18 @@ class file_input_adapter : public input_adapter_protocol
: m_file(f) : m_file(f)
{} {}
// make class move-only
file_input_adapter(const file_input_adapter&) = delete;
file_input_adapter(file_input_adapter&&) noexcept = default;
file_input_adapter& operator=(const file_input_adapter&) = delete;
file_input_adapter& operator=(file_input_adapter&&) noexcept = default;
~file_input_adapter() override = default;
std::char_traits<char>::int_type get_character() noexcept override std::char_traits<char>::int_type get_character() noexcept override
{ {
return std::fgetc(m_file); return std::fgetc(m_file);
} }
private: private:
/// the file pointer to read from /// the file pointer to read from
std::FILE* m_file; std::FILE* m_file;

View file

@ -159,6 +159,13 @@ class json_sax_dom_parser
: root(r), allow_exceptions(allow_exceptions_) : root(r), allow_exceptions(allow_exceptions_)
{} {}
// make class move-only
json_sax_dom_parser(const json_sax_dom_parser&) = delete;
json_sax_dom_parser(json_sax_dom_parser&&) noexcept = default;
json_sax_dom_parser& operator=(const json_sax_dom_parser&) = delete;
json_sax_dom_parser& operator=(json_sax_dom_parser&&) noexcept = default;
~json_sax_dom_parser() = default;
bool null() bool null()
{ {
handle_value(nullptr); handle_value(nullptr);
@ -307,7 +314,7 @@ class json_sax_dom_parser
/// the parsed JSON value /// the parsed JSON value
BasicJsonType& root; BasicJsonType& root;
/// stack to model hierarchy of values /// stack to model hierarchy of values
std::vector<BasicJsonType*> ref_stack; std::vector<BasicJsonType*> ref_stack {};
/// helper to hold the reference for the next object element /// helper to hold the reference for the next object element
BasicJsonType* object_element = nullptr; BasicJsonType* object_element = nullptr;
/// whether a syntax error occurred /// whether a syntax error occurred
@ -335,6 +342,13 @@ class json_sax_dom_callback_parser
keep_stack.push_back(true); keep_stack.push_back(true);
} }
// make class move-only
json_sax_dom_callback_parser(const json_sax_dom_callback_parser&) = delete;
json_sax_dom_callback_parser(json_sax_dom_callback_parser&&) = default;
json_sax_dom_callback_parser& operator=(const json_sax_dom_callback_parser&) = delete;
json_sax_dom_callback_parser& operator=(json_sax_dom_callback_parser&&) = default;
~json_sax_dom_callback_parser() = default;
bool null() bool null()
{ {
handle_value(nullptr); handle_value(nullptr);
@ -612,11 +626,11 @@ class json_sax_dom_callback_parser
/// the parsed JSON value /// the parsed JSON value
BasicJsonType& root; BasicJsonType& root;
/// stack to model hierarchy of values /// stack to model hierarchy of values
std::vector<BasicJsonType*> ref_stack; std::vector<BasicJsonType*> ref_stack {};
/// stack to manage which values to keep /// stack to manage which values to keep
std::vector<bool> keep_stack; std::vector<bool> keep_stack {};
/// stack to manage which object keys to keep /// stack to manage which object keys to keep
std::vector<bool> key_keep_stack; std::vector<bool> key_keep_stack {};
/// helper to hold the reference for the next object element /// helper to hold the reference for the next object element
BasicJsonType* object_element = nullptr; BasicJsonType* object_element = nullptr;
/// whether a syntax error occurred /// whether a syntax error occurred

View file

@ -3,16 +3,16 @@
#include <array> // array #include <array> // array
#include <clocale> // localeconv #include <clocale> // localeconv
#include <cstddef> // size_t #include <cstddef> // size_t
#include <cstdlib> // strtof, strtod, strtold, strtoll, strtoull
#include <cstdio> // snprintf #include <cstdio> // snprintf
#include <cstdlib> // strtof, strtod, strtold, strtoll, strtoull
#include <initializer_list> // initializer_list #include <initializer_list> // initializer_list
#include <string> // char_traits, string #include <string> // char_traits, string
#include <utility> // move #include <utility> // move
#include <vector> // vector #include <vector> // vector
#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/input/input_adapters.hpp> #include <nlohmann/detail/input/input_adapters.hpp>
#include <nlohmann/detail/input/position_t.hpp> #include <nlohmann/detail/input/position_t.hpp>
#include <nlohmann/detail/macro_scope.hpp>
namespace nlohmann namespace nlohmann
{ {
@ -1485,7 +1485,7 @@ scan_number_done:
bool next_unget = false; bool next_unget = false;
/// the start position of the current token /// the start position of the current token
position_t position; position_t position {};
/// raw input token string (for error messages) /// raw input token string (for error messages)
std::vector<char> token_string {}; std::vector<char> token_string {};

View file

@ -9,11 +9,11 @@
#include <vector> // vector #include <vector> // vector
#include <nlohmann/detail/exceptions.hpp> #include <nlohmann/detail/exceptions.hpp>
#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/meta/is_sax.hpp>
#include <nlohmann/detail/input/input_adapters.hpp> #include <nlohmann/detail/input/input_adapters.hpp>
#include <nlohmann/detail/input/json_sax.hpp> #include <nlohmann/detail/input/json_sax.hpp>
#include <nlohmann/detail/input/lexer.hpp> #include <nlohmann/detail/input/lexer.hpp>
#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/meta/is_sax.hpp>
#include <nlohmann/detail/value_t.hpp> #include <nlohmann/detail/value_t.hpp>
namespace nlohmann namespace nlohmann

View file

@ -607,7 +607,7 @@ class iter_impl
/// associated JSON instance /// associated JSON instance
pointer m_object = nullptr; pointer m_object = nullptr;
/// the actual iterator of the associated instance /// the actual iterator of the associated instance
internal_iterator<typename std::remove_const<BasicJsonType>::type> m_it; internal_iterator<typename std::remove_const<BasicJsonType>::type> m_it {};
}; };
} // namespace detail } // namespace detail
} // namespace nlohmann } // namespace nlohmann

View file

@ -1,12 +1,12 @@
#pragma once #pragma once
#include <cstddef> // size_t #include <cstddef> // size_t
#include <string> // string, to_string
#include <iterator> // input_iterator_tag #include <iterator> // input_iterator_tag
#include <string> // string, to_string
#include <tuple> // tuple_size, get, tuple_element #include <tuple> // tuple_size, get, tuple_element
#include <nlohmann/detail/value_t.hpp>
#include <nlohmann/detail/meta/type_traits.hpp> #include <nlohmann/detail/meta/type_traits.hpp>
#include <nlohmann/detail/value_t.hpp>
namespace nlohmann namespace nlohmann
{ {

View file

@ -7,8 +7,8 @@
#include <utility> // move #include <utility> // move
#include <vector> // vector #include <vector> // vector
#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/exceptions.hpp> #include <nlohmann/detail/exceptions.hpp>
#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/value_t.hpp> #include <nlohmann/detail/value_t.hpp>
namespace nlohmann namespace nlohmann

View file

@ -14,7 +14,9 @@ struct nonesuch
nonesuch() = delete; nonesuch() = delete;
~nonesuch() = delete; ~nonesuch() = delete;
nonesuch(nonesuch const&) = delete; nonesuch(nonesuch const&) = delete;
nonesuch(nonesuch const&&) = delete;
void operator=(nonesuch const&) = delete; void operator=(nonesuch const&) = delete;
void operator=(nonesuch&&) = delete;
}; };
template <class Default, template <class Default,

View file

@ -5,11 +5,11 @@
#include <type_traits> // false_type, is_constructible, is_integral, is_same, true_type #include <type_traits> // false_type, is_constructible, is_integral, is_same, true_type
#include <utility> // declval #include <utility> // declval
#include <nlohmann/json_fwd.hpp>
#include <nlohmann/detail/iterators/iterator_traits.hpp> #include <nlohmann/detail/iterators/iterator_traits.hpp>
#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/meta/cpp_future.hpp> #include <nlohmann/detail/meta/cpp_future.hpp>
#include <nlohmann/detail/meta/detected.hpp> #include <nlohmann/detail/meta/detected.hpp>
#include <nlohmann/detail/macro_scope.hpp> #include <nlohmann/json_fwd.hpp>
namespace nlohmann namespace nlohmann
{ {

View file

@ -14,8 +14,8 @@
#include <type_traits> // is_same #include <type_traits> // is_same
#include <utility> // move #include <utility> // move
#include <nlohmann/detail/exceptions.hpp>
#include <nlohmann/detail/conversions/to_chars.hpp> #include <nlohmann/detail/conversions/to_chars.hpp>
#include <nlohmann/detail/exceptions.hpp>
#include <nlohmann/detail/macro_scope.hpp> #include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/meta/cpp_future.hpp> #include <nlohmann/detail/meta/cpp_future.hpp>
#include <nlohmann/detail/output/binary_writer.hpp> #include <nlohmann/detail/output/binary_writer.hpp>
@ -278,6 +278,11 @@ class serializer
o->write_characters("null", 4); o->write_characters("null", 4);
return; return;
} }
default:
{
assert(false); // LCOV_EXCL_LINE
}
} }
} }
@ -474,6 +479,11 @@ class serializer
state = UTF8_ACCEPT; state = UTF8_ACCEPT;
break; break;
} }
default:
{
assert(false); // LCOV_EXCL_LINE
}
} }
break; break;
} }
@ -534,6 +544,11 @@ class serializer
} }
break; break;
} }
default:
{
assert(false); // LCOV_EXCL_LINE
}
} }
} }
} }

View file

@ -48,29 +48,29 @@ SOFTWARE.
#include <utility> // declval, forward, move, pair, swap #include <utility> // declval, forward, move, pair, swap
#include <vector> // vector #include <vector> // vector
#include <nlohmann/json_fwd.hpp> #include <nlohmann/adl_serializer.hpp>
#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/meta/cpp_future.hpp>
#include <nlohmann/detail/meta/type_traits.hpp>
#include <nlohmann/detail/exceptions.hpp>
#include <nlohmann/detail/value_t.hpp>
#include <nlohmann/detail/conversions/from_json.hpp> #include <nlohmann/detail/conversions/from_json.hpp>
#include <nlohmann/detail/conversions/to_json.hpp> #include <nlohmann/detail/conversions/to_json.hpp>
#include <nlohmann/detail/exceptions.hpp>
#include <nlohmann/detail/input/binary_reader.hpp>
#include <nlohmann/detail/input/input_adapters.hpp> #include <nlohmann/detail/input/input_adapters.hpp>
#include <nlohmann/detail/input/lexer.hpp> #include <nlohmann/detail/input/lexer.hpp>
#include <nlohmann/detail/input/parser.hpp> #include <nlohmann/detail/input/parser.hpp>
#include <nlohmann/detail/iterators/primitive_iterator.hpp>
#include <nlohmann/detail/iterators/internal_iterator.hpp> #include <nlohmann/detail/iterators/internal_iterator.hpp>
#include <nlohmann/detail/iterators/iter_impl.hpp> #include <nlohmann/detail/iterators/iter_impl.hpp>
#include <nlohmann/detail/iterators/iteration_proxy.hpp> #include <nlohmann/detail/iterators/iteration_proxy.hpp>
#include <nlohmann/detail/iterators/json_reverse_iterator.hpp> #include <nlohmann/detail/iterators/json_reverse_iterator.hpp>
#include <nlohmann/detail/output/output_adapters.hpp> #include <nlohmann/detail/iterators/primitive_iterator.hpp>
#include <nlohmann/detail/input/binary_reader.hpp>
#include <nlohmann/detail/output/binary_writer.hpp>
#include <nlohmann/detail/output/serializer.hpp>
#include <nlohmann/detail/json_ref.hpp>
#include <nlohmann/detail/json_pointer.hpp> #include <nlohmann/detail/json_pointer.hpp>
#include <nlohmann/adl_serializer.hpp> #include <nlohmann/detail/json_ref.hpp>
#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/meta/cpp_future.hpp>
#include <nlohmann/detail/meta/type_traits.hpp>
#include <nlohmann/detail/output/binary_writer.hpp>
#include <nlohmann/detail/output/output_adapters.hpp>
#include <nlohmann/detail/output/serializer.hpp>
#include <nlohmann/detail/value_t.hpp>
#include <nlohmann/json_fwd.hpp>
/*! /*!
@brief namespace for Niels Lohmann @brief namespace for Niels Lohmann
@ -1325,6 +1325,8 @@ class basic_json
case value_t::discarded: case value_t::discarded:
m_type = value_t::discarded; m_type = value_t::discarded;
break; break;
default:
assert(false); // LCOV_EXCL_LINE
} }
assert_invariant(); assert_invariant();
} }
@ -7695,7 +7697,7 @@ class basic_json
break; break;
} }
case patch_operations::invalid: default:
{ {
// op must be "add", "remove", "replace", "move", "copy", or // op must be "add", "remove", "replace", "move", "copy", or
// "test" // "test"

File diff suppressed because it is too large Load diff

View file

@ -149,7 +149,7 @@ class alt_string
} }
private: private:
std::string str_impl; std::string str_impl {};
friend bool ::operator<(const char*, const alt_string&); friend bool ::operator<(const char*, const alt_string&);
}; };

View file

@ -125,7 +125,7 @@ class SaxEventLogger
return false; return false;
} }
std::vector<std::string> events; std::vector<std::string> events {};
bool errored = false; bool errored = false;
}; };

View file

@ -123,7 +123,7 @@ struct SaxEventLogger : public nlohmann::json_sax<json>
return false; return false;
} }
std::vector<std::string> events; std::vector<std::string> events {};
}; };
struct SaxEventLoggerExitAfterStartObject : public SaxEventLogger struct SaxEventLoggerExitAfterStartObject : public SaxEventLogger

View file

@ -124,8 +124,10 @@ struct nocopy
struct Data struct Data
{ {
std::string a; Data() = default;
std::string b; Data(const std::string& a_, const std::string b_) : a(a_), b(b_) {}
std::string a {};
std::string b {};
}; };
void from_json(const json& j, Data& data) void from_json(const json& j, Data& data)