Skip to content

Commit

Permalink
Merge pull request #579 from Type1J/develop_feature_first_second
Browse files Browse the repository at this point in the history
Fixing assignement for iterator wrapper second, and adding unit test
  • Loading branch information
nlohmann authored May 13, 2017
2 parents 5beea35 + b78457b commit 8b88e1b
Show file tree
Hide file tree
Showing 3 changed files with 766 additions and 0 deletions.
36 changes: 36 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) const
{
return proxy.key() == key;
}

/// not equal operator (calls key())
template<typename KeyType>
bool operator!=(const KeyType& key) const
{
return proxy.key() != key;
}
};

/// helper class for second "property"
Expand All @@ -7913,6 +7927,28 @@ class basic_json
{
return proxy.value();
}

/// equal operator (calls value())
template<typename ValueType>
bool operator==(const ValueType& value) const
{
return proxy.value() == value;
}

/// not equal operator (calls value())
template<typename ValueType>
bool operator!=(const ValueType& value) const
{
return proxy.value() != value;
}

/// assignment operator (calls value())
template<typename ValueType>
iterator_value_property<ProxyType>& operator=(const ValueType& value)
{
proxy.value() = value;
return *this;
}
};

/// helper class for iteration
Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ add_executable(${JSON_UNITTEST_TARGET_NAME}
"src/unit-element_access2.cpp"
"src/unit-inspection.cpp"
"src/unit-iterator_wrapper.cpp"
"src/unit-iterator_wrapper_first_second.cpp"
"src/unit-iterators1.cpp"
"src/unit-iterators2.cpp"
"src/unit-json_patch.cpp"
Expand Down
Loading

0 comments on commit 8b88e1b

Please sign in to comment.