12USERVER_NAMESPACE_BEGIN
17template <
typename Value>
18struct ItemsWrapperValue final {
20 typename decltype(std::declval<Value&>().begin())::reference value;
26template <
typename Value>
27class ItemsWrapper final {
32 class Iterator final {
33 using Base = std::conditional_t<Const,
const Value, Value>;
34 using RawIterator =
decltype(std::declval<Base&>().begin());
37 using iterator_category = std::forward_iterator_tag;
38 using difference_type = std::ptrdiff_t;
39 using value_type = ItemsWrapperValue<Base>;
40 using reference = value_type;
44 explicit Iterator(RawIterator it)
49 Iterator(
const Iterator& other) =
default;
50 Iterator(Iterator&& other)
noexcept =
default;
52 Iterator& operator=(
const Iterator& other) =
default;
53 Iterator& operator=(Iterator&& other)
noexcept =
default;
55 reference operator*()
const {
return {it_.GetName(), *it_}; }
57 Iterator operator++(
int) {
63 Iterator& operator++() {
68 bool operator==(
const Iterator& other)
const {
return it_ == other.it_; }
70 bool operator!=(
const Iterator& other)
const {
return !(*
this == other); }
79 using iterator = Iterator<
false>;
84 using const_iterator = Iterator<
true>;
87 explicit ItemsWrapper(Value&& value)
88 : value_(
static_cast<Value&&>(value))
92 iterator begin() {
return iterator(value_.begin()); }
93 iterator end() {
return iterator(value_.end()); }
94 const_iterator begin()
const {
return const_iterator(value_.begin()); }
95 const_iterator end()
const {
return const_iterator(value_.end()); }
118template <
typename Value>
119ItemsWrapper<Value>
Items(Value&& value) {
122 return ItemsWrapper<Value>(
static_cast<Value&&>(value));