Skip to content

Commit

Permalink
Deprecate json_pointer/string_t comparisons (#3684)
Browse files Browse the repository at this point in the history
* Deprecate json_pointer/string_t comparisons

* Update documentation
  • Loading branch information
falbrechtskirchinger authored Aug 7, 2022
1 parent e1a3fb7 commit a92ccaf
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
8 changes: 7 additions & 1 deletion docs/mkdocs/docs/api/json_pointer/operator_eq.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ whether the values `lhs`/`*this` and `rhs` are equal
Constant if `lhs` and `rhs` differ in the number of reference tokens, otherwise linear in the number of reference
tokens.
## Notes
!!! warning "Deprecation"
Overload 2 is deprecated and will be removed in a future major version release.
## Examples
??? example "Example: (1) Comparing JSON pointers"
Expand Down Expand Up @@ -104,4 +110,4 @@ tokens.
## Version history

1. Added in version 2.1.0. Added C++20 member functions in version 3.11.2.
2. Added in version 3.11.2.
2. Added for backward compatibility and deprecated in version 3.11.2.
6 changes: 5 additions & 1 deletion docs/mkdocs/docs/api/json_pointer/operator_ne.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ tokens.
Since C++20 overload resolution will consider the _rewritten candidate_ generated from
[`operator==`](operator_eq.md).

!!! warning "Deprecation"

Overload 2 is deprecated and will be removed in a future major version release.

## Examples

??? example "Example: (1) Comparing JSON pointers"
Expand Down Expand Up @@ -102,4 +106,4 @@ tokens.
## Version history

1. Added in version 2.1.0.
2. Added in version 3.11.2.
2. Added for backward compatibility and deprecated in version 3.11.2.
5 changes: 5 additions & 0 deletions include/nlohmann/detail/json_pointer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ class json_pointer

/// @brief compares JSON pointer and string for equality
/// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/
JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer))
bool operator==(const string_t& rhs) const
{
return *this == json_pointer(rhs);
Expand Down Expand Up @@ -935,6 +936,7 @@ inline bool operator==(const json_pointer<RefStringTypeLhs>& lhs,

template<typename RefStringTypeLhs,
typename StringType = typename json_pointer<RefStringTypeLhs>::string_t>
JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer, json_pointer))
inline bool operator==(const json_pointer<RefStringTypeLhs>& lhs,
const StringType& rhs)
{
Expand All @@ -943,6 +945,7 @@ inline bool operator==(const json_pointer<RefStringTypeLhs>& lhs,

template<typename RefStringTypeRhs,
typename StringType = typename json_pointer<RefStringTypeRhs>::string_t>
JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer, json_pointer))
inline bool operator==(const StringType& lhs,
const json_pointer<RefStringTypeRhs>& rhs)
{
Expand All @@ -958,6 +961,7 @@ inline bool operator!=(const json_pointer<RefStringTypeLhs>& lhs,

template<typename RefStringTypeLhs,
typename StringType = typename json_pointer<RefStringTypeLhs>::string_t>
JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator!=(json_pointer, json_pointer))
inline bool operator!=(const json_pointer<RefStringTypeLhs>& lhs,
const StringType& rhs)
{
Expand All @@ -966,6 +970,7 @@ inline bool operator!=(const json_pointer<RefStringTypeLhs>& lhs,

template<typename RefStringTypeRhs,
typename StringType = typename json_pointer<RefStringTypeRhs>::string_t>
JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator!=(json_pointer, json_pointer))
inline bool operator!=(const StringType& lhs,
const json_pointer<RefStringTypeRhs>& rhs)
{
Expand Down
5 changes: 5 additions & 0 deletions single_include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14518,6 +14518,7 @@ class json_pointer

/// @brief compares JSON pointer and string for equality
/// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/
JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer))
bool operator==(const string_t& rhs) const
{
return *this == json_pointer(rhs);
Expand Down Expand Up @@ -14595,6 +14596,7 @@ inline bool operator==(const json_pointer<RefStringTypeLhs>& lhs,

template<typename RefStringTypeLhs,
typename StringType = typename json_pointer<RefStringTypeLhs>::string_t>
JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer, json_pointer))
inline bool operator==(const json_pointer<RefStringTypeLhs>& lhs,
const StringType& rhs)
{
Expand All @@ -14603,6 +14605,7 @@ inline bool operator==(const json_pointer<RefStringTypeLhs>& lhs,

template<typename RefStringTypeRhs,
typename StringType = typename json_pointer<RefStringTypeRhs>::string_t>
JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer, json_pointer))
inline bool operator==(const StringType& lhs,
const json_pointer<RefStringTypeRhs>& rhs)
{
Expand All @@ -14618,6 +14621,7 @@ inline bool operator!=(const json_pointer<RefStringTypeLhs>& lhs,

template<typename RefStringTypeLhs,
typename StringType = typename json_pointer<RefStringTypeLhs>::string_t>
JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator!=(json_pointer, json_pointer))
inline bool operator!=(const json_pointer<RefStringTypeLhs>& lhs,
const StringType& rhs)
{
Expand All @@ -14626,6 +14630,7 @@ inline bool operator!=(const json_pointer<RefStringTypeLhs>& lhs,

template<typename RefStringTypeRhs,
typename StringType = typename json_pointer<RefStringTypeRhs>::string_t>
JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator!=(json_pointer, json_pointer))
inline bool operator!=(const StringType& lhs,
const json_pointer<RefStringTypeRhs>& rhs)
{
Expand Down

0 comments on commit a92ccaf

Please sign in to comment.