Skip to content

Commit 8b88e1b

Browse files
authored
Merge pull request #579 from Type1J/develop_feature_first_second
Fixing assignement for iterator wrapper second, and adding unit test
2 parents 5beea35 + b78457b commit 8b88e1b

3 files changed

Lines changed: 766 additions & 0 deletions

File tree

src/json.hpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7894,6 +7894,20 @@ class basic_json
78947894
{
78957895
return proxy.key();
78967896
}
7897+
7898+
/// equal operator (calls key())
7899+
template<typename KeyType>
7900+
bool operator==(const KeyType& key) const
7901+
{
7902+
return proxy.key() == key;
7903+
}
7904+
7905+
/// not equal operator (calls key())
7906+
template<typename KeyType>
7907+
bool operator!=(const KeyType& key) const
7908+
{
7909+
return proxy.key() != key;
7910+
}
78977911
};
78987912

78997913
/// helper class for second "property"
@@ -7913,6 +7927,28 @@ class basic_json
79137927
{
79147928
return proxy.value();
79157929
}
7930+
7931+
/// equal operator (calls value())
7932+
template<typename ValueType>
7933+
bool operator==(const ValueType& value) const
7934+
{
7935+
return proxy.value() == value;
7936+
}
7937+
7938+
/// not equal operator (calls value())
7939+
template<typename ValueType>
7940+
bool operator!=(const ValueType& value) const
7941+
{
7942+
return proxy.value() != value;
7943+
}
7944+
7945+
/// assignment operator (calls value())
7946+
template<typename ValueType>
7947+
iterator_value_property<ProxyType>& operator=(const ValueType& value)
7948+
{
7949+
proxy.value() = value;
7950+
return *this;
7951+
}
79167952
};
79177953

79187954
/// helper class for iteration

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ add_executable(${JSON_UNITTEST_TARGET_NAME}
3030
"src/unit-element_access2.cpp"
3131
"src/unit-inspection.cpp"
3232
"src/unit-iterator_wrapper.cpp"
33+
"src/unit-iterator_wrapper_first_second.cpp"
3334
"src/unit-iterators1.cpp"
3435
"src/unit-iterators2.cpp"
3536
"src/unit-json_patch.cpp"

0 commit comments

Comments
 (0)