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) : it_(std::move(it)) {}
47 Iterator(
const Iterator& other) =
default;
48 Iterator(Iterator&& other)
noexcept =
default;
50 Iterator& operator=(
const Iterator& other) =
default;
51 Iterator& operator=(Iterator&& other)
noexcept =
default;
53 reference operator*()
const {
return {it_.GetName(), *it_}; }
55 Iterator operator++(
int) {
61 Iterator& operator++() {
66 bool operator==(
const Iterator& other)
const {
return it_ == other.it_; }
68 bool operator!=(
const Iterator& other)
const {
return !(*
this == other); }
77 using iterator = Iterator<
false>;
82 using const_iterator = Iterator<
true>;
85 explicit ItemsWrapper(Value&& value) : value_(
static_cast<Value&&>(value)) {}
88 iterator begin() {
return iterator(value_.begin()); }
89 iterator end() {
return iterator(value_.end()); }
90 const_iterator begin()
const {
return const_iterator(value_.begin()); }
91 const_iterator end()
const {
return const_iterator(value_.end()); }
110template <
typename Value>
111ItemsWrapper<Value>
Items(Value&& value) {
114 return ItemsWrapper<Value>(
static_cast<Value&&>(value));