Skip to content

Commit 6a656ed

Browse files
committed
Adding first and second properties to iteration_proxy_internal
1 parent 2afbd33 commit 6a656ed

1 file changed

Lines changed: 42 additions & 1 deletion

File tree

src/json.hpp

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7877,6 +7877,44 @@ class basic_json
78777877
class iteration_proxy
78787878
{
78797879
private:
7880+
/// helper class for first "property"
7881+
template<typename ProxyType>
7882+
class iterator_key_property
7883+
{
7884+
private:
7885+
/// the reference to the proxy
7886+
ProxyType& proxy;
7887+
7888+
public:
7889+
explicit iterator_key_property(ProxyType& proxyRef) noexcept
7890+
: proxy(proxyRef) {}
7891+
7892+
/// conversion operator (calls key())
7893+
operator typename basic_json::string_t() const
7894+
{
7895+
return proxy.key();
7896+
}
7897+
};
7898+
7899+
/// helper class for second "property"
7900+
template<typename ProxyType>
7901+
class iterator_value_property
7902+
{
7903+
private:
7904+
/// the reference to the proxy
7905+
ProxyType& proxy;
7906+
7907+
public:
7908+
explicit iterator_value_property(ProxyType& proxyRef) noexcept
7909+
: proxy(proxyRef) {}
7910+
7911+
/// conversion operator (calls value())
7912+
operator typename IteratorType::reference() const
7913+
{
7914+
return proxy.value();
7915+
}
7916+
};
7917+
78807918
/// helper class for iteration
78817919
class iteration_proxy_internal
78827920
{
@@ -7887,8 +7925,11 @@ class basic_json
78877925
size_t array_index = 0;
78887926

78897927
public:
7928+
iterator_key_property<iteration_proxy_internal> first;
7929+
iterator_value_property<iteration_proxy_internal> second;
7930+
78907931
explicit iteration_proxy_internal(IteratorType it) noexcept
7891-
: anchor(it)
7932+
: anchor(it), first(*this), second(*this)
78927933
{}
78937934

78947935
/// dereference operator (needed for range-based for)

0 commit comments

Comments
 (0)