1# <small>nlohmann::json_pointer::</small>operator!= 2 3```cpp 4// until C++20 5template<typename RefStringTypeLhs, typename RefStringTypeRhs> 6bool operator!=( 7 const json_pointer<RefStringTypeLhs>& lhs, 8 const json_pointer<RefStringTypeRhs>& rhs) noexcept; // (1) 9 10template<typename RefStringTypeLhs, typename StringType> 11bool operator!=( 12 const json_pointer<RefStringTypeLhs>& lhs, 13 const StringType& rhs); // (2) 14 15template<typename RefStringTypeRhs, typename StringType> 16bool operator!=( 17 const StringType& lhs, 18 const json_pointer<RefStringTypeRhs>& rhs); // (2) 19``` 20 211. Compares two JSON pointers for inequality by comparing their reference tokens. 22 232. Compares a JSON pointer and a string or a string and a JSON pointer for inequality by converting the string to a 24 JSON pointer and comparing the JSON pointers according to 1. 25 26## Template parameters 27 28`RefStringTypeLhs`, `RefStringTypeRhs` 29: the string type of the left-hand side or right-hand side JSON pointer, respectively 30 31`StringType` 32: the string type derived from the `json_pointer` operand ([`json_pointer::string_t`](string_t.md)) 33 34## Parameters 35 36`lhs` (in) 37: first value to consider 38 39`rhs` (in) 40: second value to consider 41 42## Return value 43 44whether the values `lhs`/`*this` and `rhs` are not equal 45 46## Exception safety 47 481. No-throw guarantee: this function never throws exceptions. 492. Strong exception safety: if an exception occurs, the original value stays intact. 50 51## Exceptions 52 531. (none) 542. The function can throw the following exceptions: 55 - Throws [parse_error.107](../../home/exceptions.md#jsonexceptionparse_error107) if the given JSON pointer `s` is 56 nonempty and does not begin with a slash (`/`); see example below. 57 - Throws [parse_error.108](../../home/exceptions.md#jsonexceptionparse_error108) if a tilde (`~`) in the given JSON 58 pointer `s` is not followed by `0` (representing `~`) or `1` (representing `/`); see example below. 59 60## Complexity 61 62Constant if `lhs` and `rhs` differ in the number of reference tokens, otherwise linear in the number of reference 63tokens. 64 65## Notes 66 67!!! note "Operator overload resolution" 68 69 Since C++20 overload resolution will consider the _rewritten candidate_ generated from 70 [`operator==`](operator_eq.md). 71 72!!! warning "Deprecation" 73 74 Overload 2 is deprecated and will be removed in a future major version release. 75 76## Examples 77 78??? example "Example: (1) Comparing JSON pointers" 79 80 The example demonstrates comparing JSON pointers. 81 82 ```cpp 83 --8<-- "examples/json_pointer__operator__notequal.cpp" 84 ``` 85 86 Output: 87 88 ``` 89 --8<-- "examples/json_pointer__operator__notequal.output" 90 ``` 91 92??? example "Example: (2) Comparing JSON pointers and strings" 93 94 The example demonstrates comparing JSON pointers and strings, and when doing so may raise an exception. 95 96 ```cpp 97 --8<-- "examples/json_pointer__operator__notequal_stringtype.cpp" 98 ``` 99 100 Output: 101 102 ``` 103 --8<-- "examples/json_pointer__operator__notequal_stringtype.output" 104 ``` 105 106## Version history 107 1081. Added in version 2.1.0. 1092. Added for backward compatibility and deprecated in version 3.11.2. 110