From 6a656ed375d96b64ddbb0d7d364fb03627f9b3ac Mon Sep 17 00:00:00 2001 From: Jay Sistar Date: Wed, 10 May 2017 13:20:52 +0000 Subject: [PATCH] Adding first and second properties to iteration_proxy_internal --- src/json.hpp | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/json.hpp b/src/json.hpp index 62b4cfb75..8e2d8749c 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -7877,6 +7877,44 @@ class basic_json class iteration_proxy { private: + /// helper class for first "property" + template + class iterator_key_property + { + private: + /// the reference to the proxy + ProxyType& proxy; + + public: + explicit iterator_key_property(ProxyType& proxyRef) noexcept + : proxy(proxyRef) {} + + /// conversion operator (calls key()) + operator typename basic_json::string_t() const + { + return proxy.key(); + } + }; + + /// helper class for second "property" + template + class iterator_value_property + { + private: + /// the reference to the proxy + ProxyType& proxy; + + public: + explicit iterator_value_property(ProxyType& proxyRef) noexcept + : proxy(proxyRef) {} + + /// conversion operator (calls value()) + operator typename IteratorType::reference() const + { + return proxy.value(); + } + }; + /// helper class for iteration class iteration_proxy_internal { @@ -7887,8 +7925,11 @@ class basic_json size_t array_index = 0; public: + iterator_key_property first; + iterator_value_property second; + explicit iteration_proxy_internal(IteratorType it) noexcept - : anchor(it) + : anchor(it), first(*this), second(*this) {} /// dereference operator (needed for range-based for)