Skip to content

Commit

Permalink
Adding equal and not equal operators to proxys.
Browse files Browse the repository at this point in the history
  • Loading branch information
Type1J committed May 11, 2017
1 parent d6c78da commit 00d841b
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand Down

0 comments on commit 00d841b

Please sign in to comment.