Skip to content

Commit bbd2e16

Browse files
authored
Fix deprecation warning (#4161)
1 parent 6e36c72 commit bbd2e16

4 files changed

Lines changed: 38 additions & 12 deletions

File tree

docs/mkdocs/docs/api/operator_literal_json.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# <small>nlohmann::</small>operator""_json
22

33
```cpp
4-
json operator "" _json(const char* s, std::size_t n);
4+
json operator ""_json(const char* s, std::size_t n);
55
```
66

77
This operator implements a user-defined string literal for JSON objects. It can be used by adding `#!cpp _json` to a
88
string literal and returns a [`json`](json.md) object if no parse error occurred.
99

1010
It is recommended to bring the operator into scope using any of the following lines:
1111
```cpp
12-
using nlohmann::literals::operator "" _json;
12+
using nlohmann::literals::operator ""_json;
1313
using namespace nlohmann::literals;
1414
using namespace nlohmann::json_literals;
1515
using namespace nlohmann::literals::json_literals;

docs/mkdocs/docs/api/operator_literal_json_pointer.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# <small>nlohmann::</small>operator""_json_pointer
22

33
```cpp
4-
json_pointer operator "" _json_pointer(const char* s, std::size_t n);
4+
json_pointer operator ""_json_pointer(const char* s, std::size_t n);
55
```
66

77
This operator implements a user-defined string literal for JSON Pointers. It can be used by adding `#!cpp _json_pointer`
88
to a string literal and returns a [`json_pointer`](json_pointer/index.md) object if no parse error occurred.
99

1010
It is recommended to bring the operator into scope using any of the following lines:
1111
```cpp
12-
using nlohmann::literals::operator "" _json_pointer;
12+
using nlohmann::literals::operator ""_json_pointer;
1313
using namespace nlohmann::literals;
1414
using namespace nlohmann::json_literals;
1515
using namespace nlohmann::literals::json_literals;

include/nlohmann/json.hpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5162,15 +5162,23 @@ inline namespace json_literals
51625162
/// @brief user-defined string literal for JSON values
51635163
/// @sa https://json.nlohmann.me/api/basic_json/operator_literal_json/
51645164
JSON_HEDLEY_NON_NULL(1)
5165-
inline nlohmann::json operator "" _json(const char* s, std::size_t n)
5165+
#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
5166+
inline nlohmann::json operator ""_json(const char* s, std::size_t n)
5167+
#else
5168+
inline nlohmann::json operator "" _json(const char* s, std::size_t n)
5169+
#endif
51665170
{
51675171
return nlohmann::json::parse(s, s + n);
51685172
}
51695173

51705174
/// @brief user-defined string literal for JSON pointer
51715175
/// @sa https://json.nlohmann.me/api/basic_json/operator_literal_json_pointer/
51725176
JSON_HEDLEY_NON_NULL(1)
5173-
inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n)
5177+
#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
5178+
inline nlohmann::json::json_pointer operator ""_json_pointer(const char* s, std::size_t n)
5179+
#else
5180+
inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n)
5181+
#endif
51745182
{
51755183
return nlohmann::json::json_pointer(std::string(s, n));
51765184
}
@@ -5234,8 +5242,13 @@ inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC
52345242
} // namespace std
52355243

52365244
#if JSON_USE_GLOBAL_UDLS
5237-
using nlohmann::literals::json_literals::operator "" _json; // NOLINT(misc-unused-using-decls,google-global-names-in-headers)
5238-
using nlohmann::literals::json_literals::operator "" _json_pointer; //NOLINT(misc-unused-using-decls,google-global-names-in-headers)
5245+
#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
5246+
using nlohmann::literals::json_literals::operator ""_json; // NOLINT(misc-unused-using-decls,google-global-names-in-headers)
5247+
using nlohmann::literals::json_literals::operator ""_json_pointer; //NOLINT(misc-unused-using-decls,google-global-names-in-headers)
5248+
#else
5249+
using nlohmann::literals::json_literals::operator "" _json; // NOLINT(misc-unused-using-decls,google-global-names-in-headers)
5250+
using nlohmann::literals::json_literals::operator "" _json_pointer; //NOLINT(misc-unused-using-decls,google-global-names-in-headers)
5251+
#endif
52395252
#endif
52405253

52415254
#include <nlohmann/detail/macro_unscope.hpp>

single_include/nlohmann/json.hpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24368,15 +24368,23 @@ inline namespace json_literals
2436824368
/// @brief user-defined string literal for JSON values
2436924369
/// @sa https://json.nlohmann.me/api/basic_json/operator_literal_json/
2437024370
JSON_HEDLEY_NON_NULL(1)
24371-
inline nlohmann::json operator "" _json(const char* s, std::size_t n)
24371+
#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
24372+
inline nlohmann::json operator ""_json(const char* s, std::size_t n)
24373+
#else
24374+
inline nlohmann::json operator "" _json(const char* s, std::size_t n)
24375+
#endif
2437224376
{
2437324377
return nlohmann::json::parse(s, s + n);
2437424378
}
2437524379

2437624380
/// @brief user-defined string literal for JSON pointer
2437724381
/// @sa https://json.nlohmann.me/api/basic_json/operator_literal_json_pointer/
2437824382
JSON_HEDLEY_NON_NULL(1)
24379-
inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n)
24383+
#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
24384+
inline nlohmann::json::json_pointer operator ""_json_pointer(const char* s, std::size_t n)
24385+
#else
24386+
inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n)
24387+
#endif
2438024388
{
2438124389
return nlohmann::json::json_pointer(std::string(s, n));
2438224390
}
@@ -24440,8 +24448,13 @@ inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC
2444024448
} // namespace std
2444124449

2444224450
#if JSON_USE_GLOBAL_UDLS
24443-
using nlohmann::literals::json_literals::operator "" _json; // NOLINT(misc-unused-using-decls,google-global-names-in-headers)
24444-
using nlohmann::literals::json_literals::operator "" _json_pointer; //NOLINT(misc-unused-using-decls,google-global-names-in-headers)
24451+
#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
24452+
using nlohmann::literals::json_literals::operator ""_json; // NOLINT(misc-unused-using-decls,google-global-names-in-headers)
24453+
using nlohmann::literals::json_literals::operator ""_json_pointer; //NOLINT(misc-unused-using-decls,google-global-names-in-headers)
24454+
#else
24455+
using nlohmann::literals::json_literals::operator "" _json; // NOLINT(misc-unused-using-decls,google-global-names-in-headers)
24456+
using nlohmann::literals::json_literals::operator "" _json_pointer; //NOLINT(misc-unused-using-decls,google-global-names-in-headers)
24457+
#endif
2444524458
#endif
2444624459

2444724460
// #include <nlohmann/detail/macro_unscope.hpp>

0 commit comments

Comments
 (0)