From 7e3245786c63c0923186b2b38c9c874ed2cc3942 Mon Sep 17 00:00:00 2001 From: Trevor Welsby Date: Sat, 23 Jan 2016 17:03:45 +1000 Subject: [PATCH 1/7] Fixed issue #171 - added extra operator[] template overloads --- src/json.hpp | 106 +++++++++++++++++++++++++++++++++++++--------- src/json.hpp.re2c | 106 +++++++++++++++++++++++++++++++++++++--------- test/unit.cpp | 48 +++++++++++++++++++++ 3 files changed, 218 insertions(+), 42 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index ac362dcf..63bc8026 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -3062,8 +3062,6 @@ class basic_json the object and filled with a `null` value to make `key` a valid reference. In case the value was `null` before, it is converted to an object. - @note This function is required for compatibility reasons with Clang. - @param[in] key key of the element to access @return reference to the element at key @a key @@ -3083,25 +3081,9 @@ class basic_json @since version 1.0.0 */ template - reference operator[](const T (&key)[n]) + reference operator[](T* (&key)[n]) { - // implicitly convert null to object - if (is_null()) - { - m_type = value_t::object; - m_value = value_t::object; - } - - // at only works for objects - if (is_object()) - { - assert(m_value.object != nullptr); - return m_value.object->operator[](key); - } - else - { - throw std::domain_error("cannot use operator[] with " + type_name()); - } + return operator[](static_cast(key)); } /*! @@ -3134,7 +3116,89 @@ class basic_json @since version 1.0.0 */ template - const_reference operator[](const T (&key)[n]) const + const_reference operator[](T* (&key)[n]) const + { + return operator[](static_cast(key)); + } + + /*! + @brief access specified object element + + Returns a reference to the element at with specified key @a key. + + @note If @a key is not found in the object, then it is silently added to + the object and filled with a `null` value to make `key` a valid reference. + In case the value was `null` before, it is converted to an object. + + @param[in] key key of the element to access + + @return reference to the element at key @a key + + @throw std::domain_error if JSON is not an object or null; example: + `"cannot use operator[] with null"` + + @complexity Logarithmic in the size of the container. + + @liveexample{The example below shows how object elements can be read and + written using the [] operator.,operatorarray__key_type} + + @sa @ref at(const typename object_t::key_type&) for access by reference + with range checking + @sa @ref value() for access by value with a default value + + @since version 1.0.1 + */ + template + reference operator[](T* key) + { + // implicitly convert null to object + if (is_null()) + { + m_type = value_t::object; + m_value = value_t::object; + } + + // at only works for objects + if (is_object()) + { + assert(m_value.object != nullptr); + return m_value.object->operator[](key); + } + else + { + throw std::domain_error("cannot use operator[] with " + type_name()); + } + } + + /*! + @brief read-only access specified object element + + Returns a const reference to the element at with specified key @a key. No + bounds checking is performed. + + @warning If the element with key @a key does not exist, the behavior is + undefined. + + @param[in] key key of the element to access + + @return const reference to the element at key @a key + + @throw std::domain_error if JSON is not an object; example: `"cannot use + operator[] with null"` + + @complexity Logarithmic in the size of the container. + + @liveexample{The example below shows how object elements can be read using + the [] operator.,operatorarray__key_type_const} + + @sa @ref at(const typename object_t::key_type&) for access by reference + with range checking + @sa @ref value() for access by value with a default value + + @since version 1.0.1 + */ + template + const_reference operator[](T* key) const { // at only works for objects if (is_object()) diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index c7ee44f5..a3e7c790 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -3062,8 +3062,6 @@ class basic_json the object and filled with a `null` value to make `key` a valid reference. In case the value was `null` before, it is converted to an object. - @note This function is required for compatibility reasons with Clang. - @param[in] key key of the element to access @return reference to the element at key @a key @@ -3083,25 +3081,9 @@ class basic_json @since version 1.0.0 */ template - reference operator[](const T (&key)[n]) + reference operator[](T* (&key)[n]) { - // implicitly convert null to object - if (is_null()) - { - m_type = value_t::object; - m_value = value_t::object; - } - - // at only works for objects - if (is_object()) - { - assert(m_value.object != nullptr); - return m_value.object->operator[](key); - } - else - { - throw std::domain_error("cannot use operator[] with " + type_name()); - } + return operator[](static_cast(key)); } /*! @@ -3134,7 +3116,89 @@ class basic_json @since version 1.0.0 */ template - const_reference operator[](const T (&key)[n]) const + const_reference operator[](T* (&key)[n]) const + { + return operator[](static_cast(key)); + } + + /*! + @brief access specified object element + + Returns a reference to the element at with specified key @a key. + + @note If @a key is not found in the object, then it is silently added to + the object and filled with a `null` value to make `key` a valid reference. + In case the value was `null` before, it is converted to an object. + + @param[in] key key of the element to access + + @return reference to the element at key @a key + + @throw std::domain_error if JSON is not an object or null; example: + `"cannot use operator[] with null"` + + @complexity Logarithmic in the size of the container. + + @liveexample{The example below shows how object elements can be read and + written using the [] operator.,operatorarray__key_type} + + @sa @ref at(const typename object_t::key_type&) for access by reference + with range checking + @sa @ref value() for access by value with a default value + + @since version 1.0.1 + */ + template + reference operator[](T* key) + { + // implicitly convert null to object + if (is_null()) + { + m_type = value_t::object; + m_value = value_t::object; + } + + // at only works for objects + if (is_object()) + { + assert(m_value.object != nullptr); + return m_value.object->operator[](key); + } + else + { + throw std::domain_error("cannot use operator[] with " + type_name()); + } + } + + /*! + @brief read-only access specified object element + + Returns a const reference to the element at with specified key @a key. No + bounds checking is performed. + + @warning If the element with key @a key does not exist, the behavior is + undefined. + + @param[in] key key of the element to access + + @return const reference to the element at key @a key + + @throw std::domain_error if JSON is not an object; example: `"cannot use + operator[] with null"` + + @complexity Logarithmic in the size of the container. + + @liveexample{The example below shows how object elements can be read using + the [] operator.,operatorarray__key_type_const} + + @sa @ref at(const typename object_t::key_type&) for access by reference + with range checking + @sa @ref value() for access by value with a default value + + @since version 1.0.1 + */ + template + const_reference operator[](T* key) const { // at only works for objects if (is_object()) diff --git a/test/unit.cpp b/test/unit.cpp index 8b3bc19b..773978ec 100644 --- a/test/unit.cpp +++ b/test/unit.cpp @@ -11504,4 +11504,52 @@ TEST_CASE("regression tests") { CHECK(json::parse("\"\\ud80c\\udc60abc\"").get() == u8"\U00013060abc"); } + + SECTION("issue #144 - Cannot index by key of type static constexpr const char*") + { + json j; + + // Non-const access with key as "char []" + char array_key[] = "Key1"; + CHECK_NOTHROW(j[array_key] = 1); + CHECK(j[array_key] == json(1)); + + // Non-const access with key as "const char[]" + const char const_array_key[] = "Key2"; + CHECK_NOTHROW(j[const_array_key] = 2); + CHECK(j[const_array_key] == json(2)); + + // Non-const access with key as "char *" + char _ptr_key[] = "Key3"; + char * ptr_key = &_ptr_key[0]; + CHECK_NOTHROW(j[ptr_key] = 3); + CHECK(j[ptr_key] == json(3)); + + // Non-const access with key as "const char *" + const char * const_ptr_key = "Key4"; + CHECK_NOTHROW(j[const_ptr_key] = 4); + CHECK(j[const_ptr_key] == json(4)); + + // Non-const access with key as "static constexpr const char *" + static constexpr const char* constexpr_ptr_key = "Key5"; + CHECK_NOTHROW(j[constexpr_ptr_key] = 5); + CHECK(j[constexpr_ptr_key] == json(5)); + + const json j_const = j; + + // Non-const access with key as "char []" + CHECK(j_const[array_key] == json(1)); + + // Non-const access with key as "const char[]" + CHECK(j_const[const_array_key] == json(2)); + + // Non-const access with key as "char *" + CHECK(j_const[ptr_key] == json(3)); + + // Non-const access with key as "const char *" + CHECK(j_const[const_ptr_key] == json(4)); + + // Non-const access with key as "static constexpr const char *" + CHECK(j_const[constexpr_ptr_key] == json(5)); + } } From bd0f3001c6154a8720bd19c06e22956f78ee6db2 Mon Sep 17 00:00:00 2001 From: Trevor Welsby Date: Sat, 23 Jan 2016 17:31:58 +1000 Subject: [PATCH 2/7] Fix typo in new unit.hpp comments --- test/unit.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/unit.cpp b/test/unit.cpp index 773978ec..282c6f90 100644 --- a/test/unit.cpp +++ b/test/unit.cpp @@ -11537,19 +11537,19 @@ TEST_CASE("regression tests") const json j_const = j; - // Non-const access with key as "char []" + // Const access with key as "char []" CHECK(j_const[array_key] == json(1)); - // Non-const access with key as "const char[]" + // Const access with key as "const char[]" CHECK(j_const[const_array_key] == json(2)); - // Non-const access with key as "char *" + //Const access with key as "char *" CHECK(j_const[ptr_key] == json(3)); - // Non-const access with key as "const char *" + // Const access with key as "const char *" CHECK(j_const[const_ptr_key] == json(4)); - // Non-const access with key as "static constexpr const char *" + // Const access with key as "static constexpr const char *" CHECK(j_const[constexpr_ptr_key] == json(5)); } } From 3a1403409fc12d042608b381e891ca377de300b6 Mon Sep 17 00:00:00 2001 From: Trevor Welsby Date: Sat, 23 Jan 2016 17:45:30 +1000 Subject: [PATCH 3/7] Issue #185 - remove approx() and use #pragma to kill warnings --- src/json.hpp | 27 +++++++++++++++------------ src/json.hpp.re2c | 27 +++++++++++++++------------ test/unit.cpp | 5 +++++ 3 files changed, 35 insertions(+), 24 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index ac362dcf..3af7dbf9 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -65,6 +65,12 @@ Class @ref nlohmann::basic_json is a good entry point for the documentation. #endif #endif +// disable float-equal warnings on GCC/clang +#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wfloat-equal" +#endif + // enable ssize_t for MSVC #ifdef _MSC_VER #include @@ -100,12 +106,6 @@ struct has_mapped_type static constexpr bool value = sizeof(test(0)) == 1; }; -/// "equality" comparison for floating point numbers -template -static bool approx(const T a, const T b) -{ - return not (a > b or a < b); -} } /*! @@ -4785,7 +4785,7 @@ class basic_json } case value_t::number_float: { - return approx(lhs.m_value.number_float, rhs.m_value.number_float); + return lhs.m_value.number_float == rhs.m_value.number_float; } default: { @@ -4795,13 +4795,11 @@ class basic_json } else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float) { - return approx(static_cast(lhs.m_value.number_integer), - rhs.m_value.number_float); + return static_cast(lhs.m_value.number_integer == rhs.m_value.number_float); } else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer) { - return approx(lhs.m_value.number_float, - static_cast(rhs.m_value.number_integer)); + return lhs.m_value.number_float == static_cast(rhs.m_value.number_integer); } return false; } @@ -7560,7 +7558,7 @@ basic_json_parser_64: // check if conversion loses precision const auto int_val = static_cast(float_val); - if (approx(float_val, static_cast(int_val))) + if (float_val == static_cast(int_val)) { // we would not lose precision -> return int result.m_type = value_t::number_integer; @@ -7705,4 +7703,9 @@ inline nlohmann::json operator "" _json(const char* s, std::size_t) return nlohmann::json::parse(reinterpret_cast(s)); } +// restore GCC/clang diagnostic settings +#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) + #pragma GCC diagnostic pop +#endif + #endif diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index c7ee44f5..bacc3feb 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -65,6 +65,12 @@ Class @ref nlohmann::basic_json is a good entry point for the documentation. #endif #endif +// disable float-equal warnings on GCC/clang +#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wfloat-equal" +#endif + // enable ssize_t for MSVC #ifdef _MSC_VER #include @@ -100,12 +106,6 @@ struct has_mapped_type static constexpr bool value = sizeof(test(0)) == 1; }; -/// "equality" comparison for floating point numbers -template -static bool approx(const T a, const T b) -{ - return not (a > b or a < b); -} } /*! @@ -4785,7 +4785,7 @@ class basic_json } case value_t::number_float: { - return approx(lhs.m_value.number_float, rhs.m_value.number_float); + return lhs.m_value.number_float == rhs.m_value.number_float; } default: { @@ -4795,13 +4795,11 @@ class basic_json } else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float) { - return approx(static_cast(lhs.m_value.number_integer), - rhs.m_value.number_float); + return static_cast(lhs.m_value.number_integer == rhs.m_value.number_float); } else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer) { - return approx(lhs.m_value.number_float, - static_cast(rhs.m_value.number_integer)); + return lhs.m_value.number_float == static_cast(rhs.m_value.number_integer); } return false; } @@ -7242,7 +7240,7 @@ class basic_json // check if conversion loses precision const auto int_val = static_cast(float_val); - if (approx(float_val, static_cast(int_val))) + if (float_val == static_cast(int_val)) { // we would not lose precision -> return int result.m_type = value_t::number_integer; @@ -7387,4 +7385,9 @@ inline nlohmann::json operator "" _json(const char* s, std::size_t) return nlohmann::json::parse(reinterpret_cast(s)); } +// restore GCC/clang diagnostic settings +#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) + #pragma GCC diagnostic pop +#endif + #endif diff --git a/test/unit.cpp b/test/unit.cpp index 8b3bc19b..8f12eca0 100644 --- a/test/unit.cpp +++ b/test/unit.cpp @@ -25,6 +25,11 @@ #include "json.hpp" using nlohmann::json; +// disable float-equal warnings on GCC/clang +#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) +#pragma GCC diagnostic ignored "-Wfloat-equal" +#endif + TEST_CASE("constructors") { SECTION("create an empty value with a given type") From 600ad330c5605b12e7052aa7209c4b1c57d05841 Mon Sep 17 00:00:00 2001 From: Niels Date: Sun, 24 Jan 2016 11:00:54 +0100 Subject: [PATCH 4/7] cleanup after PR #189 --- README.md | 3 +- src/json.hpp | 1079 +++++++++++++++++++++++++++++++-------------- src/json.hpp.re2c | 16 +- test/unit.cpp | 8 +- 4 files changed, 755 insertions(+), 351 deletions(-) diff --git a/README.md b/README.md index 68d4a1fb..b985bfa4 100644 --- a/README.md +++ b/README.md @@ -388,6 +388,7 @@ I deeply appreciate the help of the following people. - [406345](https://github.com/406345) fixed two small warnings. - [Glen Fernandes](https://github.com/glenfe) noted a potential portability problem in the `has_mapped_type` function. - [Corbin Hughes](https://github.com/nibroc) fixed some typos in the contribution guidelines. +- [twelsby](https://github.com/twelsby) fixed the array subscript operator. Thanks a lot for helping out! @@ -404,7 +405,7 @@ $ make $ ./json_unit "*" =============================================================================== -All tests passed (3343239 assertions in 28 test cases) +All tests passed (3343318 assertions in 29 test cases) ``` For more information, have a look at the file [.travis.yml](https://github.com/nlohmann/json/blob/master/.travis.yml). diff --git a/src/json.hpp b/src/json.hpp index 63bc8026..6c6ccdd0 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -2671,14 +2671,14 @@ class basic_json @since version 1.0.0 */ - template::value - and not std::is_same::value + template < typename ValueType, typename + std::enable_if < + not std::is_pointer::value + and not std::is_same::value #ifndef _MSC_VER // Fix for issue #167 operator<< abiguity under VS2015 - and not std::is_same>::value + and not std::is_same>::value #endif - , int>::type = 0> + , int >::type = 0 > operator ValueType() const { // delegate the call to get<>() const @@ -3081,7 +3081,7 @@ class basic_json @since version 1.0.0 */ template - reference operator[](T* (&key)[n]) + reference operator[](T * (&key)[n]) { return operator[](static_cast(key)); } @@ -3116,7 +3116,7 @@ class basic_json @since version 1.0.0 */ template - const_reference operator[](T* (&key)[n]) const + const_reference operator[](T * (&key)[n]) const { return operator[](static_cast(key)); } @@ -6811,386 +6811,789 @@ class basic_json m_start = m_cursor; assert(m_start != nullptr); - - { - lexer_char_t yych; - unsigned int yyaccept = 0; - static const unsigned char yybm[] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 32, 32, 0, 0, 32, 0, 0, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 96, 64, 0, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 192, 192, 192, 192, 192, 192, 192, 192, - 192, 192, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 0, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - }; - if ((m_limit - m_cursor) < 5) yyfill(); // LCOV_EXCL_LINE; - yych = *m_cursor; - if (yych <= ':') { - if (yych <= ' ') { - if (yych <= '\n') { - if (yych <= 0x00) goto basic_json_parser_28; - if (yych <= 0x08) goto basic_json_parser_30; - if (yych >= '\n') goto basic_json_parser_4; - } else { - if (yych == '\r') goto basic_json_parser_2; - if (yych <= 0x1F) goto basic_json_parser_30; + + { + lexer_char_t yych; + unsigned int yyaccept = 0; + static const unsigned char yybm[] = + { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 32, 32, 0, 0, 32, 0, 0, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 96, 64, 0, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 192, 192, 192, 192, 192, 192, 192, 192, + 192, 192, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 0, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + }; + if ((m_limit - m_cursor) < 5) + { + yyfill(); // LCOV_EXCL_LINE; } - } else { - if (yych <= ',') { - if (yych == '"') goto basic_json_parser_27; - if (yych <= '+') goto basic_json_parser_30; - goto basic_json_parser_16; - } else { - if (yych <= '/') { - if (yych <= '-') goto basic_json_parser_23; - goto basic_json_parser_30; - } else { - if (yych <= '0') goto basic_json_parser_24; - if (yych <= '9') goto basic_json_parser_26; - goto basic_json_parser_18; + yych = *m_cursor; + if (yych <= ':') + { + if (yych <= ' ') + { + if (yych <= '\n') + { + if (yych <= 0x00) + { + goto basic_json_parser_28; + } + if (yych <= 0x08) + { + goto basic_json_parser_30; + } + if (yych >= '\n') + { + goto basic_json_parser_4; + } + } + else + { + if (yych == '\r') + { + goto basic_json_parser_2; + } + if (yych <= 0x1F) + { + goto basic_json_parser_30; + } + } + } + else + { + if (yych <= ',') + { + if (yych == '"') + { + goto basic_json_parser_27; + } + if (yych <= '+') + { + goto basic_json_parser_30; + } + goto basic_json_parser_16; + } + else + { + if (yych <= '/') + { + if (yych <= '-') + { + goto basic_json_parser_23; + } + goto basic_json_parser_30; + } + else + { + if (yych <= '0') + { + goto basic_json_parser_24; + } + if (yych <= '9') + { + goto basic_json_parser_26; + } + goto basic_json_parser_18; + } + } } } - } - } else { - if (yych <= 'n') { - if (yych <= ']') { - if (yych == '[') goto basic_json_parser_8; - if (yych <= '\\') goto basic_json_parser_30; - goto basic_json_parser_10; - } else { - if (yych == 'f') goto basic_json_parser_22; - if (yych <= 'm') goto basic_json_parser_30; - goto basic_json_parser_20; - } - } else { - if (yych <= '{') { - if (yych == 't') goto basic_json_parser_21; - if (yych <= 'z') goto basic_json_parser_30; - goto basic_json_parser_12; - } else { - if (yych <= '}') { - if (yych <= '|') goto basic_json_parser_30; - goto basic_json_parser_14; - } else { - if (yych == 0xEF) goto basic_json_parser_6; - goto basic_json_parser_30; + else + { + if (yych <= 'n') + { + if (yych <= ']') + { + if (yych == '[') + { + goto basic_json_parser_8; + } + if (yych <= '\\') + { + goto basic_json_parser_30; + } + goto basic_json_parser_10; + } + else + { + if (yych == 'f') + { + goto basic_json_parser_22; + } + if (yych <= 'm') + { + goto basic_json_parser_30; + } + goto basic_json_parser_20; + } + } + else + { + if (yych <= '{') + { + if (yych == 't') + { + goto basic_json_parser_21; + } + if (yych <= 'z') + { + goto basic_json_parser_30; + } + goto basic_json_parser_12; + } + else + { + if (yych <= '}') + { + if (yych <= '|') + { + goto basic_json_parser_30; + } + goto basic_json_parser_14; + } + else + { + if (yych == 0xEF) + { + goto basic_json_parser_6; + } + goto basic_json_parser_30; + } + } } } - } - } basic_json_parser_2: - ++m_cursor; - yych = *m_cursor; - goto basic_json_parser_5; + ++m_cursor; + yych = *m_cursor; + goto basic_json_parser_5; basic_json_parser_3: - { return scan(); } + { + return scan(); + } basic_json_parser_4: - ++m_cursor; - if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE; - yych = *m_cursor; + ++m_cursor; + if (m_limit <= m_cursor) + { + yyfill(); // LCOV_EXCL_LINE; + } + yych = *m_cursor; basic_json_parser_5: - if (yybm[0+yych] & 32) { - goto basic_json_parser_4; - } - goto basic_json_parser_3; + if (yybm[0 + yych] & 32) + { + goto basic_json_parser_4; + } + goto basic_json_parser_3; basic_json_parser_6: - yyaccept = 0; - yych = *(m_marker = ++m_cursor); - if (yych == 0xBB) goto basic_json_parser_64; + yyaccept = 0; + yych = *(m_marker = ++m_cursor); + if (yych == 0xBB) + { + goto basic_json_parser_64; + } basic_json_parser_7: - { return token_type::parse_error; } + { + return token_type::parse_error; + } basic_json_parser_8: - ++m_cursor; - { return token_type::begin_array; } + ++m_cursor; + { + return token_type::begin_array; + } basic_json_parser_10: - ++m_cursor; - { return token_type::end_array; } + ++m_cursor; + { + return token_type::end_array; + } basic_json_parser_12: - ++m_cursor; - { return token_type::begin_object; } + ++m_cursor; + { + return token_type::begin_object; + } basic_json_parser_14: - ++m_cursor; - { return token_type::end_object; } + ++m_cursor; + { + return token_type::end_object; + } basic_json_parser_16: - ++m_cursor; - { return token_type::value_separator; } + ++m_cursor; + { + return token_type::value_separator; + } basic_json_parser_18: - ++m_cursor; - { return token_type::name_separator; } + ++m_cursor; + { + return token_type::name_separator; + } basic_json_parser_20: - yyaccept = 0; - yych = *(m_marker = ++m_cursor); - if (yych == 'u') goto basic_json_parser_60; - goto basic_json_parser_7; + yyaccept = 0; + yych = *(m_marker = ++m_cursor); + if (yych == 'u') + { + goto basic_json_parser_60; + } + goto basic_json_parser_7; basic_json_parser_21: - yyaccept = 0; - yych = *(m_marker = ++m_cursor); - if (yych == 'r') goto basic_json_parser_56; - goto basic_json_parser_7; + yyaccept = 0; + yych = *(m_marker = ++m_cursor); + if (yych == 'r') + { + goto basic_json_parser_56; + } + goto basic_json_parser_7; basic_json_parser_22: - yyaccept = 0; - yych = *(m_marker = ++m_cursor); - if (yych == 'a') goto basic_json_parser_51; - goto basic_json_parser_7; + yyaccept = 0; + yych = *(m_marker = ++m_cursor); + if (yych == 'a') + { + goto basic_json_parser_51; + } + goto basic_json_parser_7; basic_json_parser_23: - yych = *++m_cursor; - if (yych <= '/') goto basic_json_parser_7; - if (yych <= '0') goto basic_json_parser_50; - if (yych <= '9') goto basic_json_parser_41; - goto basic_json_parser_7; + yych = *++m_cursor; + if (yych <= '/') + { + goto basic_json_parser_7; + } + if (yych <= '0') + { + goto basic_json_parser_50; + } + if (yych <= '9') + { + goto basic_json_parser_41; + } + goto basic_json_parser_7; basic_json_parser_24: - yyaccept = 1; - yych = *(m_marker = ++m_cursor); - if (yych <= 'D') { - if (yych == '.') goto basic_json_parser_43; - } else { - if (yych <= 'E') goto basic_json_parser_44; - if (yych == 'e') goto basic_json_parser_44; - } + yyaccept = 1; + yych = *(m_marker = ++m_cursor); + if (yych <= 'D') + { + if (yych == '.') + { + goto basic_json_parser_43; + } + } + else + { + if (yych <= 'E') + { + goto basic_json_parser_44; + } + if (yych == 'e') + { + goto basic_json_parser_44; + } + } basic_json_parser_25: - { return token_type::value_number; } + { + return token_type::value_number; + } basic_json_parser_26: - yyaccept = 1; - yych = *(m_marker = ++m_cursor); - goto basic_json_parser_42; + yyaccept = 1; + yych = *(m_marker = ++m_cursor); + goto basic_json_parser_42; basic_json_parser_27: - yyaccept = 0; - yych = *(m_marker = ++m_cursor); - if (yych <= 0x0F) goto basic_json_parser_7; - goto basic_json_parser_32; + yyaccept = 0; + yych = *(m_marker = ++m_cursor); + if (yych <= 0x0F) + { + goto basic_json_parser_7; + } + goto basic_json_parser_32; basic_json_parser_28: - ++m_cursor; - { return token_type::end_of_input; } + ++m_cursor; + { + return token_type::end_of_input; + } basic_json_parser_30: - yych = *++m_cursor; - goto basic_json_parser_7; + yych = *++m_cursor; + goto basic_json_parser_7; basic_json_parser_31: - ++m_cursor; - if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE; - yych = *m_cursor; + ++m_cursor; + if (m_limit <= m_cursor) + { + yyfill(); // LCOV_EXCL_LINE; + } + yych = *m_cursor; basic_json_parser_32: - if (yybm[0+yych] & 64) { - goto basic_json_parser_31; - } - if (yych <= 0x0F) goto basic_json_parser_33; - if (yych <= '"') goto basic_json_parser_35; - goto basic_json_parser_34; -basic_json_parser_33: - m_cursor = m_marker; - if (yyaccept == 0) { - goto basic_json_parser_7; - } else { - goto basic_json_parser_25; - } -basic_json_parser_34: - ++m_cursor; - if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE; - yych = *m_cursor; - if (yych <= 'e') { - if (yych <= '/') { - if (yych == '"') goto basic_json_parser_31; - if (yych <= '.') goto basic_json_parser_33; - goto basic_json_parser_31; - } else { - if (yych <= '\\') { - if (yych <= '[') goto basic_json_parser_33; + if (yybm[0 + yych] & 64) + { goto basic_json_parser_31; - } else { - if (yych == 'b') goto basic_json_parser_31; + } + if (yych <= 0x0F) + { goto basic_json_parser_33; } - } - } else { - if (yych <= 'q') { - if (yych <= 'f') goto basic_json_parser_31; - if (yych == 'n') goto basic_json_parser_31; - goto basic_json_parser_33; - } else { - if (yych <= 's') { - if (yych <= 'r') goto basic_json_parser_31; - goto basic_json_parser_33; - } else { - if (yych <= 't') goto basic_json_parser_31; - if (yych <= 'u') goto basic_json_parser_37; - goto basic_json_parser_33; + if (yych <= '"') + { + goto basic_json_parser_35; + } + goto basic_json_parser_34; +basic_json_parser_33: + m_cursor = m_marker; + if (yyaccept == 0) + { + goto basic_json_parser_7; + } + else + { + goto basic_json_parser_25; + } +basic_json_parser_34: + ++m_cursor; + if (m_limit <= m_cursor) + { + yyfill(); // LCOV_EXCL_LINE; + } + yych = *m_cursor; + if (yych <= 'e') + { + if (yych <= '/') + { + if (yych == '"') + { + goto basic_json_parser_31; + } + if (yych <= '.') + { + goto basic_json_parser_33; + } + goto basic_json_parser_31; + } + else + { + if (yych <= '\\') + { + if (yych <= '[') + { + goto basic_json_parser_33; + } + goto basic_json_parser_31; + } + else + { + if (yych == 'b') + { + goto basic_json_parser_31; + } + goto basic_json_parser_33; + } + } + } + else + { + if (yych <= 'q') + { + if (yych <= 'f') + { + goto basic_json_parser_31; + } + if (yych == 'n') + { + goto basic_json_parser_31; + } + goto basic_json_parser_33; + } + else + { + if (yych <= 's') + { + if (yych <= 'r') + { + goto basic_json_parser_31; + } + goto basic_json_parser_33; + } + else + { + if (yych <= 't') + { + goto basic_json_parser_31; + } + if (yych <= 'u') + { + goto basic_json_parser_37; + } + goto basic_json_parser_33; + } + } } - } - } basic_json_parser_35: - ++m_cursor; - { return token_type::value_string; } + ++m_cursor; + { + return token_type::value_string; + } basic_json_parser_37: - ++m_cursor; - if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE; - yych = *m_cursor; - if (yych <= '@') { - if (yych <= '/') goto basic_json_parser_33; - if (yych >= ':') goto basic_json_parser_33; - } else { - if (yych <= 'F') goto basic_json_parser_38; - if (yych <= '`') goto basic_json_parser_33; - if (yych >= 'g') goto basic_json_parser_33; - } + ++m_cursor; + if (m_limit <= m_cursor) + { + yyfill(); // LCOV_EXCL_LINE; + } + yych = *m_cursor; + if (yych <= '@') + { + if (yych <= '/') + { + goto basic_json_parser_33; + } + if (yych >= ':') + { + goto basic_json_parser_33; + } + } + else + { + if (yych <= 'F') + { + goto basic_json_parser_38; + } + if (yych <= '`') + { + goto basic_json_parser_33; + } + if (yych >= 'g') + { + goto basic_json_parser_33; + } + } basic_json_parser_38: - ++m_cursor; - if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE; - yych = *m_cursor; - if (yych <= '@') { - if (yych <= '/') goto basic_json_parser_33; - if (yych >= ':') goto basic_json_parser_33; - } else { - if (yych <= 'F') goto basic_json_parser_39; - if (yych <= '`') goto basic_json_parser_33; - if (yych >= 'g') goto basic_json_parser_33; - } + ++m_cursor; + if (m_limit <= m_cursor) + { + yyfill(); // LCOV_EXCL_LINE; + } + yych = *m_cursor; + if (yych <= '@') + { + if (yych <= '/') + { + goto basic_json_parser_33; + } + if (yych >= ':') + { + goto basic_json_parser_33; + } + } + else + { + if (yych <= 'F') + { + goto basic_json_parser_39; + } + if (yych <= '`') + { + goto basic_json_parser_33; + } + if (yych >= 'g') + { + goto basic_json_parser_33; + } + } basic_json_parser_39: - ++m_cursor; - if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE; - yych = *m_cursor; - if (yych <= '@') { - if (yych <= '/') goto basic_json_parser_33; - if (yych >= ':') goto basic_json_parser_33; - } else { - if (yych <= 'F') goto basic_json_parser_40; - if (yych <= '`') goto basic_json_parser_33; - if (yych >= 'g') goto basic_json_parser_33; - } + ++m_cursor; + if (m_limit <= m_cursor) + { + yyfill(); // LCOV_EXCL_LINE; + } + yych = *m_cursor; + if (yych <= '@') + { + if (yych <= '/') + { + goto basic_json_parser_33; + } + if (yych >= ':') + { + goto basic_json_parser_33; + } + } + else + { + if (yych <= 'F') + { + goto basic_json_parser_40; + } + if (yych <= '`') + { + goto basic_json_parser_33; + } + if (yych >= 'g') + { + goto basic_json_parser_33; + } + } basic_json_parser_40: - ++m_cursor; - if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE; - yych = *m_cursor; - if (yych <= '@') { - if (yych <= '/') goto basic_json_parser_33; - if (yych <= '9') goto basic_json_parser_31; - goto basic_json_parser_33; - } else { - if (yych <= 'F') goto basic_json_parser_31; - if (yych <= '`') goto basic_json_parser_33; - if (yych <= 'f') goto basic_json_parser_31; - goto basic_json_parser_33; - } + ++m_cursor; + if (m_limit <= m_cursor) + { + yyfill(); // LCOV_EXCL_LINE; + } + yych = *m_cursor; + if (yych <= '@') + { + if (yych <= '/') + { + goto basic_json_parser_33; + } + if (yych <= '9') + { + goto basic_json_parser_31; + } + goto basic_json_parser_33; + } + else + { + if (yych <= 'F') + { + goto basic_json_parser_31; + } + if (yych <= '`') + { + goto basic_json_parser_33; + } + if (yych <= 'f') + { + goto basic_json_parser_31; + } + goto basic_json_parser_33; + } basic_json_parser_41: - yyaccept = 1; - m_marker = ++m_cursor; - if ((m_limit - m_cursor) < 3) yyfill(); // LCOV_EXCL_LINE; - yych = *m_cursor; + yyaccept = 1; + m_marker = ++m_cursor; + if ((m_limit - m_cursor) < 3) + { + yyfill(); // LCOV_EXCL_LINE; + } + yych = *m_cursor; basic_json_parser_42: - if (yybm[0+yych] & 128) { - goto basic_json_parser_41; - } - if (yych <= 'D') { - if (yych != '.') goto basic_json_parser_25; - } else { - if (yych <= 'E') goto basic_json_parser_44; - if (yych == 'e') goto basic_json_parser_44; - goto basic_json_parser_25; - } + if (yybm[0 + yych] & 128) + { + goto basic_json_parser_41; + } + if (yych <= 'D') + { + if (yych != '.') + { + goto basic_json_parser_25; + } + } + else + { + if (yych <= 'E') + { + goto basic_json_parser_44; + } + if (yych == 'e') + { + goto basic_json_parser_44; + } + goto basic_json_parser_25; + } basic_json_parser_43: - yych = *++m_cursor; - if (yych <= '/') goto basic_json_parser_33; - if (yych <= '9') goto basic_json_parser_48; - goto basic_json_parser_33; + yych = *++m_cursor; + if (yych <= '/') + { + goto basic_json_parser_33; + } + if (yych <= '9') + { + goto basic_json_parser_48; + } + goto basic_json_parser_33; basic_json_parser_44: - yych = *++m_cursor; - if (yych <= ',') { - if (yych != '+') goto basic_json_parser_33; - } else { - if (yych <= '-') goto basic_json_parser_45; - if (yych <= '/') goto basic_json_parser_33; - if (yych <= '9') goto basic_json_parser_46; - goto basic_json_parser_33; - } + yych = *++m_cursor; + if (yych <= ',') + { + if (yych != '+') + { + goto basic_json_parser_33; + } + } + else + { + if (yych <= '-') + { + goto basic_json_parser_45; + } + if (yych <= '/') + { + goto basic_json_parser_33; + } + if (yych <= '9') + { + goto basic_json_parser_46; + } + goto basic_json_parser_33; + } basic_json_parser_45: - yych = *++m_cursor; - if (yych <= '/') goto basic_json_parser_33; - if (yych >= ':') goto basic_json_parser_33; + yych = *++m_cursor; + if (yych <= '/') + { + goto basic_json_parser_33; + } + if (yych >= ':') + { + goto basic_json_parser_33; + } basic_json_parser_46: - ++m_cursor; - if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE; - yych = *m_cursor; - if (yych <= '/') goto basic_json_parser_25; - if (yych <= '9') goto basic_json_parser_46; - goto basic_json_parser_25; + ++m_cursor; + if (m_limit <= m_cursor) + { + yyfill(); // LCOV_EXCL_LINE; + } + yych = *m_cursor; + if (yych <= '/') + { + goto basic_json_parser_25; + } + if (yych <= '9') + { + goto basic_json_parser_46; + } + goto basic_json_parser_25; basic_json_parser_48: - yyaccept = 1; - m_marker = ++m_cursor; - if ((m_limit - m_cursor) < 3) yyfill(); // LCOV_EXCL_LINE; - yych = *m_cursor; - if (yych <= 'D') { - if (yych <= '/') goto basic_json_parser_25; - if (yych <= '9') goto basic_json_parser_48; - goto basic_json_parser_25; - } else { - if (yych <= 'E') goto basic_json_parser_44; - if (yych == 'e') goto basic_json_parser_44; - goto basic_json_parser_25; - } + yyaccept = 1; + m_marker = ++m_cursor; + if ((m_limit - m_cursor) < 3) + { + yyfill(); // LCOV_EXCL_LINE; + } + yych = *m_cursor; + if (yych <= 'D') + { + if (yych <= '/') + { + goto basic_json_parser_25; + } + if (yych <= '9') + { + goto basic_json_parser_48; + } + goto basic_json_parser_25; + } + else + { + if (yych <= 'E') + { + goto basic_json_parser_44; + } + if (yych == 'e') + { + goto basic_json_parser_44; + } + goto basic_json_parser_25; + } basic_json_parser_50: - yyaccept = 1; - yych = *(m_marker = ++m_cursor); - if (yych <= 'D') { - if (yych == '.') goto basic_json_parser_43; - goto basic_json_parser_25; - } else { - if (yych <= 'E') goto basic_json_parser_44; - if (yych == 'e') goto basic_json_parser_44; - goto basic_json_parser_25; - } + yyaccept = 1; + yych = *(m_marker = ++m_cursor); + if (yych <= 'D') + { + if (yych == '.') + { + goto basic_json_parser_43; + } + goto basic_json_parser_25; + } + else + { + if (yych <= 'E') + { + goto basic_json_parser_44; + } + if (yych == 'e') + { + goto basic_json_parser_44; + } + goto basic_json_parser_25; + } basic_json_parser_51: - yych = *++m_cursor; - if (yych != 'l') goto basic_json_parser_33; - yych = *++m_cursor; - if (yych != 's') goto basic_json_parser_33; - yych = *++m_cursor; - if (yych != 'e') goto basic_json_parser_33; - ++m_cursor; - { return token_type::literal_false; } + yych = *++m_cursor; + if (yych != 'l') + { + goto basic_json_parser_33; + } + yych = *++m_cursor; + if (yych != 's') + { + goto basic_json_parser_33; + } + yych = *++m_cursor; + if (yych != 'e') + { + goto basic_json_parser_33; + } + ++m_cursor; + { + return token_type::literal_false; + } basic_json_parser_56: - yych = *++m_cursor; - if (yych != 'u') goto basic_json_parser_33; - yych = *++m_cursor; - if (yych != 'e') goto basic_json_parser_33; - ++m_cursor; - { return token_type::literal_true; } + yych = *++m_cursor; + if (yych != 'u') + { + goto basic_json_parser_33; + } + yych = *++m_cursor; + if (yych != 'e') + { + goto basic_json_parser_33; + } + ++m_cursor; + { + return token_type::literal_true; + } basic_json_parser_60: - yych = *++m_cursor; - if (yych != 'l') goto basic_json_parser_33; - yych = *++m_cursor; - if (yych != 'l') goto basic_json_parser_33; - ++m_cursor; - { return token_type::literal_null; } + yych = *++m_cursor; + if (yych != 'l') + { + goto basic_json_parser_33; + } + yych = *++m_cursor; + if (yych != 'l') + { + goto basic_json_parser_33; + } + ++m_cursor; + { + return token_type::literal_null; + } basic_json_parser_64: - yych = *++m_cursor; - if (yych != 0xBF) goto basic_json_parser_33; - ++m_cursor; - { return scan(); } - } + yych = *++m_cursor; + if (yych != 0xBF) + { + goto basic_json_parser_33; + } + ++m_cursor; + { + return scan(); + } + } } diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index a3e7c790..c596669e 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -2671,14 +2671,14 @@ class basic_json @since version 1.0.0 */ - template::value - and not std::is_same::value + template < typename ValueType, typename + std::enable_if < + not std::is_pointer::value + and not std::is_same::value #ifndef _MSC_VER // Fix for issue #167 operator<< abiguity under VS2015 - and not std::is_same>::value + and not std::is_same>::value #endif - , int>::type = 0> + , int >::type = 0 > operator ValueType() const { // delegate the call to get<>() const @@ -3081,7 +3081,7 @@ class basic_json @since version 1.0.0 */ template - reference operator[](T* (&key)[n]) + reference operator[](T * (&key)[n]) { return operator[](static_cast(key)); } @@ -3116,7 +3116,7 @@ class basic_json @since version 1.0.0 */ template - const_reference operator[](T* (&key)[n]) const + const_reference operator[](T * (&key)[n]) const { return operator[](static_cast(key)); } diff --git a/test/unit.cpp b/test/unit.cpp index 282c6f90..aa3ff48d 100644 --- a/test/unit.cpp +++ b/test/unit.cpp @@ -11500,12 +11500,12 @@ TEST_CASE("regression tests") CHECK(s2 == "value"); } - SECTION("character following a surrogate pair is skipped") + SECTION("issue #146 - character following a surrogate pair is skipped") { CHECK(json::parse("\"\\ud80c\\udc60abc\"").get() == u8"\U00013060abc"); } - SECTION("issue #144 - Cannot index by key of type static constexpr const char*") + SECTION("issue #171 - Cannot index by key of type static constexpr const char*") { json j; @@ -11521,12 +11521,12 @@ TEST_CASE("regression tests") // Non-const access with key as "char *" char _ptr_key[] = "Key3"; - char * ptr_key = &_ptr_key[0]; + char* ptr_key = &_ptr_key[0]; CHECK_NOTHROW(j[ptr_key] = 3); CHECK(j[ptr_key] == json(3)); // Non-const access with key as "const char *" - const char * const_ptr_key = "Key4"; + const char* const_ptr_key = "Key4"; CHECK_NOTHROW(j[const_ptr_key] = 4); CHECK(j[const_ptr_key] == json(4)); From 8a0490a011d806e278b5464c459d277c524337ed Mon Sep 17 00:00:00 2001 From: Niels Date: Sun, 24 Jan 2016 13:04:55 +0100 Subject: [PATCH 5/7] cleanup --- README.md | 2 +- test/unit.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b985bfa4..6d45c2a2 100644 --- a/README.md +++ b/README.md @@ -388,7 +388,7 @@ I deeply appreciate the help of the following people. - [406345](https://github.com/406345) fixed two small warnings. - [Glen Fernandes](https://github.com/glenfe) noted a potential portability problem in the `has_mapped_type` function. - [Corbin Hughes](https://github.com/nibroc) fixed some typos in the contribution guidelines. -- [twelsby](https://github.com/twelsby) fixed the array subscript operator. +- [twelsby](https://github.com/twelsby) fixed the array subscript operator and an issue that failed the MSVC build. Thanks a lot for helping out! diff --git a/test/unit.cpp b/test/unit.cpp index 949788e9..94b5084c 100644 --- a/test/unit.cpp +++ b/test/unit.cpp @@ -27,7 +27,7 @@ using nlohmann::json; // disable float-equal warnings on GCC/clang #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) -#pragma GCC diagnostic ignored "-Wfloat-equal" + #pragma GCC diagnostic ignored "-Wfloat-equal" #endif TEST_CASE("constructors") From d7d1e5564861d827316a9f93d31c4e390e86151f Mon Sep 17 00:00:00 2001 From: Niels Date: Sun, 24 Jan 2016 13:28:08 +0100 Subject: [PATCH 6/7] applied include-what-you-use --- src/json.hpp | 3 +++ src/json.hpp.re2c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/json.hpp b/src/json.hpp index 8755cd33..36280c16 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -43,7 +43,9 @@ Class @ref nlohmann::basic_json is a good entry point for the documentation. #include #include #include +#include #include +#include #include #include #include @@ -53,6 +55,7 @@ Class @ref nlohmann::basic_json is a good entry point for the documentation. #include #include #include +#include #include #include #include diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 207208d4..b88d8fb0 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -43,7 +43,9 @@ Class @ref nlohmann::basic_json is a good entry point for the documentation. #include #include #include +#include #include +#include #include #include #include @@ -53,6 +55,7 @@ Class @ref nlohmann::basic_json is a good entry point for the documentation. #include #include #include +#include #include #include #include From 8b6e0dc02d7f18f761ecea4db977d8bcc3e56bbf Mon Sep 17 00:00:00 2001 From: Niels Date: Sun, 24 Jan 2016 13:28:16 +0100 Subject: [PATCH 7/7] small addition --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3e6258d4..0171a244 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -62,6 +62,7 @@ Please understand that I cannot accept pull requests changing only file `src/jso - The C++11 support varies between different **compilers** and versions. Please note the [list of supported compilers](https://github.com/nlohmann/json/blob/master/README.md#supported-compilers). Some compilers like GCC 4.8 (and earlier), Clang 3.3 (and earlier), or Microsoft Visual Studio 13.0 and earlier are known not to work due to missing or incomplete C++11 support. Please refrain from proposing changes that work around these compiler's limitations with `#ifdef`s or other means. - Specifically, I am aware of compilation problems with **Microsoft Visual Studio** (there even is an [issue label](https://github.com/nlohmann/json/issues?utf8=✓&q=label%3A%22visual+studio%22+) for these kind of bugs). I understand that even in 2016, complete C++11 support isn't there yet. But please also understand that I do not want to drop features or uglify the code just to make Microsoft's sub-standard compiler happy. The past has shown that there are ways to express the functionality such that the code compiles with the most recent MSVC - unfortunately, this is not the main objective of the project. - Please refrain from proposing changes that would **break [JSON](http://json.org) conformance**. If you propose a conformant extension of JSON to be supported by the library, please motivate this extension. +- Please do not open pull requests that address **multiple issues**. ## Wanted