MCPcopy Create free account
hub / github.com/Open-GD/OpenGD / iteration_proxy_value

Class iteration_proxy_value

Source/external/json.hpp:5114–5232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5112 target = to_string(value);
5113}
5114template<typename IteratorType> class iteration_proxy_value
5115{
5116 public:
5117 using difference_type = std::ptrdiff_t;
5118 using value_type = iteration_proxy_value;
5119 using pointer = value_type *;
5120 using reference = value_type &;
5121 using iterator_category = std::input_iterator_tag;
5122 using string_type = typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().key() ) >::type >::type;
5123
5124 private:
5125 /// the iterator
5126 IteratorType anchor{};
5127 /// an index for arrays (used to create key names)
5128 std::size_t array_index = 0;
5129 /// last stringified array index
5130 mutable std::size_t array_index_last = 0;
5131 /// a string representation of the array index
5132 mutable string_type array_index_str = "0";
5133 /// an empty string (to return a reference for primitive values)
5134 string_type empty_str{};
5135
5136 public:
5137 explicit iteration_proxy_value() = default;
5138 explicit iteration_proxy_value(IteratorType it, std::size_t array_index_ = 0)
5139 noexcept(std::is_nothrow_move_constructible<IteratorType>::value
5140 && std::is_nothrow_default_constructible<string_type>::value)
5141 : anchor(std::move(it))
5142 , array_index(array_index_)
5143 {}
5144
5145 iteration_proxy_value(iteration_proxy_value const&) = default;
5146 iteration_proxy_value& operator=(iteration_proxy_value const&) = default;
5147 // older GCCs are a bit fussy and require explicit noexcept specifiers on defaulted functions
5148 iteration_proxy_value(iteration_proxy_value&&)
5149 noexcept(std::is_nothrow_move_constructible<IteratorType>::value
5150 && std::is_nothrow_move_constructible<string_type>::value) = default;
5151 iteration_proxy_value& operator=(iteration_proxy_value&&)
5152 noexcept(std::is_nothrow_move_assignable<IteratorType>::value
5153 && std::is_nothrow_move_assignable<string_type>::value) = default;
5154 ~iteration_proxy_value() = default;
5155
5156 /// dereference operator (needed for range-based for)
5157 const iteration_proxy_value& operator*() const
5158 {
5159 return *this;
5160 }
5161
5162 /// increment operator (needed for range-based for)
5163 iteration_proxy_value& operator++()
5164 {
5165 ++anchor;
5166 ++array_index;
5167
5168 return *this;
5169 }
5170
5171 iteration_proxy_value operator++(int)& // NOLINT(cert-dcl21-cpp)

Callers 1

operator++Method · 0.85

Calls 2

int_to_stringFunction · 0.85
keyMethod · 0.45

Tested by

no test coverage detected