Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing assignement for iterator wrapper second, and adding unit test #579

Merged
merged 3 commits into from
May 13, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adding equal and not equal operators to proxys.
  • Loading branch information
Type1J committed May 11, 2017
commit 00d841bfda5dea2d21261bdefa62c9274554bd05
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