mirror of
https://github.com/nlohmann/json.git
synced 2025-07-27 00:41:05 +03:00
Adding equal and not equal operators to proxys.
This commit is contained in:
28
src/json.hpp
28
src/json.hpp
@ -7894,6 +7894,20 @@ class basic_json
|
||||
{
|
||||
return proxy.key();
|
||||
}
|
||||
|
||||
/// equal operator (calls key())
|
||||
template<typename KeyType>
|
||||
bool operator==(const KeyType& key)
|
||||
{
|
||||
return proxy.key() == key;
|
||||
}
|
||||
|
||||
/// not equal operator (calls key())
|
||||
template<typename KeyType>
|
||||
bool operator!=(const KeyType& key)
|
||||
{
|
||||
return proxy.key() != key;
|
||||
}
|
||||
};
|
||||
|
||||
/// helper class for second "property"
|
||||
@ -7914,6 +7928,20 @@ class basic_json
|
||||
return proxy.value();
|
||||
}
|
||||
|
||||
/// equal operator (calls value())
|
||||
template<typename ValueType>
|
||||
bool operator==(const ValueType& value)
|
||||
{
|
||||
return proxy.value() == value;
|
||||
}
|
||||
|
||||
/// not equal operator (calls value())
|
||||
template<typename ValueType>
|
||||
bool operator!=(const ValueType& value)
|
||||
{
|
||||
return proxy.value() != value;
|
||||
}
|
||||
|
||||
/// assignment operator (calls value())
|
||||
template<typename ValueType>
|
||||
iterator_value_property<ProxyType>& operator=(const ValueType& value)
|
||||
|
Reference in New Issue
Block a user