mirror of
https://github.com/nlohmann/json
synced 2024-11-30 23:50:08 +00:00
Adding equal and not equal operators to proxys.
This commit is contained in:
parent
d6c78dacd8
commit
00d841bfda
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)
|
||||
|
Loading…
Reference in New Issue
Block a user