12USERVER_NAMESPACE_BEGIN
19template <
typename Value>
20class ItemsWrapper final {
24 using RawIterator =
decltype(std::declval<Value>().begin());
28 typename RawIterator::reference value;
31 using iterator_category = std::forward_iterator_tag;
32 using difference_type = std::ptrdiff_t;
36 explicit Iterator(RawIterator it) : it_(it) {}
37 Iterator(
const Iterator& other) =
default;
38 Iterator(
Iterator&& other)
noexcept =
default;
43 ItValue operator*()
const {
return {it_.GetName(), *it_}; }
55 bool operator==(
const Iterator& other)
const {
return it_ == other.it_; }
57 bool operator!=(
const Iterator& other)
const {
return !(*
this == other); }
63 ItemsWrapper(Value&& value) : value_(
static_cast<Value&&>(value)) {}
65 auto begin()
const {
return cbegin(); }
66 auto end()
const {
return cend(); }
67 auto cbegin()
const {
return Iterator(value_.begin()); }
68 auto cend()
const {
return Iterator(value_.end()); }
79template <
typename Value>
80ItemsWrapper<Value>
Items(Value&& value) {
83 return ItemsWrapper<Value>(
static_cast<Value&&>(value));