14 template <
typename It,
typename Mapper>
17 using iterator_category =
18 typename std::iterator_traits<It>::iterator_category;
20 using value_type = decltype(std::declval<Mapper>()(*std::declval<It>()));
21 using difference_type =
typename std::iterator_traits<It>::difference_type;
22 using reference = std::add_lvalue_reference_t<value_type>;
23 using pointer = std::add_pointer_t<reference>;
27 : it_(std::move(it)) {}
29 constexpr
explicit mapping_iterator_adapter(It it, Mapper mapper)
31 , mapper_(std::move(mapper)) {}
33 template <
class U,
class V>
34 constexpr mapping_iterator_adapter(
37 , mapper_(other.mapper_) {}
39 template <
class U,
class V>
43 swap(mapper_, other.mapper_);
46 template <
class U,
class V>
47 constexpr mapping_iterator_adapter& operator=(
53 constexpr mapping_iterator_adapter(
const mapping_iterator_adapter&) =
55 constexpr mapping_iterator_adapter(mapping_iterator_adapter&&) noexcept =
57 constexpr mapping_iterator_adapter& operator=(
58 const mapping_iterator_adapter&) =
default;
59 constexpr mapping_iterator_adapter& operator=(
60 mapping_iterator_adapter&&) noexcept =
default;
62 constexpr It base()
const {
return it_; }
64 constexpr value_type operator*()
const {
return mapper_(*it_); }
66 constexpr
auto operator-> ()
const {
return &mapper_(*it_); }
68 constexpr value_type operator[](difference_type n)
const {
69 return mapper_(it_[n]);
72 constexpr mapping_iterator_adapter& operator++() {
76 constexpr mapping_iterator_adapter& operator--() {
81 constexpr mapping_iterator_adapter operator++(
int) {
82 return mapping_iterator_adapter{it_++, mapper_};
84 constexpr mapping_iterator_adapter operator--(
int) {
85 return mapping_iterator_adapter{it_--, mapper_};
88 constexpr mapping_iterator_adapter operator+(difference_type n)
const {
92 constexpr mapping_iterator_adapter operator-(difference_type n)
const {
97 constexpr mapping_iterator_adapter& operator+=(difference_type n) {
102 constexpr mapping_iterator_adapter& operator-=(difference_type n) {
111 template <
typename U,
typename V>
112 friend class mapping_iterator_adapter;
117 template <
class A,
class B,
class C,
class D>
120 return lhs.base() == rhs.base();
123 template <
class A,
class B,
class C,
class D>
126 return lhs.base() != rhs.base();
129 template <
class A,
class B,
class C,
class D>
130 constexpr
bool operator<(const mapping_iterator_adapter<A, B>& lhs,
132 return lhs.base() < rhs.base();
135 template <
class A,
class B,
class C,
class D>
136 constexpr
bool operator<=(const mapping_iterator_adapter<A, B>& lhs,
138 return lhs.base() <= rhs.base();
141 template <
class A,
class B,
class C,
class D>
144 return lhs.base() > rhs.base();
147 template <
class A,
class B,
class C,
class D>
150 return lhs.base() >= rhs.base();
155 template <
class U,
class V>
157 typename mapping_iterator_adapter<U, V>::difference_type n,
162 template <
class U,
class V>
164 typename mapping_iterator_adapter<U, V>::difference_type n,
169 template <
class U,
class V>
170 constexpr
typename mapping_iterator_adapter<U, V>::difference_type operator-(
173 return a.base() - b.base();
178 template <
class U,
class V>
Definition: allocator.h:6
Definition: mapping_iterator_adapter.h:15