Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
reverse_iterator.hpp
Go to the documentation of this file.
1// Copyright 2026, Toyota Motor Corporation
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5///
6/// @file reverse_iterator.hpp
7/// @brief Provides a backport of the constexpr implementation of @c std::reverse_iterator .
8///
9#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_ITERATOR_REVERSE_ITERATOR_HPP_
10#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_ITERATOR_REVERSE_ITERATOR_HPP_
11
12// IWYU pragma: private, include "arene/base/iterator.hpp"
13// IWYU pragma: friend "(arene/base(?!/tests)|stdlib/include/stdlib_detail)/.*"
14
15// parasoft-begin-suppress AUTOSAR-A7_1_5-a-2 "Trailing return syntax permitted by A7-1-5 Permit #1 v1.0.0"
16
17// parasoft-begin-suppress AUTOSAR-A16_2_2-a-2 "Arene Base aggregate headers permitted by A16-2-2 Permit #1"
25#include "arene/base/iterator/detail/iter_concept.hpp"
29#include "arene/base/stdlib_choice/declval.hpp"
30#include "arene/base/stdlib_choice/enable_if.hpp"
31#include "arene/base/stdlib_choice/forward.hpp"
32#include "arene/base/stdlib_choice/is_base_of.hpp"
33#include "arene/base/stdlib_choice/is_constructible.hpp"
34#include "arene/base/stdlib_choice/is_convertible.hpp"
35#include "arene/base/stdlib_choice/is_copy_constructible.hpp"
36#include "arene/base/stdlib_choice/is_pointer.hpp"
37#include "arene/base/stdlib_choice/is_same.hpp"
38#include "arene/base/stdlib_choice/iterator_tags.hpp"
39#include "arene/base/stdlib_choice/iterator_traits.hpp"
43
44#if ARENE_IS_OFF(ARENE_STDLIB_LIBARENECXX)
45#include "arene/base/iterator/detail/std_reverse_iterator_enabled.hpp"
46#else
47#include "arene/base/iterator/detail/std_reverse_iterator_disabled.hpp"
48#endif
49
50// parasoft-end-suppress AUTOSAR-A16_2_2-a-2
51
52// parasoft-begin-suppress CERT_C-EXP37-a-3 "False positive: The rule does not mention naming all parameters"
53
54namespace arene {
55namespace base {
56
57namespace reverse_iterator_detail {
58
59// parasoft-begin-suppress AUTOSAR-A5_0_3-a "This abstraction is generic and
60// does not restrict the value type of the base iterator"
61
62/// @brief Base class for @c reverse_iterator providing operations that do not depend on pointer-ness of underlying
63/// iterator.
64template <typename Itr>
65class reverse_iterator_base {
66 public:
67 static_assert(
69 std::is_base_of<std::bidirectional_iterator_tag, iterator_detail::iter_concept_t<Itr>>::value,
70 "Iterator category or concept must be at least bidirectional_iterator to be reversed."
71 );
72
73 /// @brief Equivalent to @c value_type for the underlying iterator.
74 using value_type = typename std::iterator_traits<Itr>::value_type;
75 /// @brief Equivalent to @c reference for the underlying iterator.
76 using reference = typename std::iterator_traits<Itr>::reference;
77 /// @brief Equivalent to @c pointer for the underlying iterator.
78 using pointer = typename std::iterator_traits<Itr>::pointer;
79 /// @brief Equivalent to @c difference_type for the underlying iterator.
80 using difference_type = typename std::iterator_traits<Itr>::difference_type;
81 /// @brief Equivalent to @c iterator_category for the underlying iterator.
82 using iterator_category = typename std::iterator_traits<Itr>::iterator_category;
83 /// @brief The type of the wrapped iterator
84 using iterator_type = Itr;
85
86 protected:
87 // This weird declaration order is needed due to a bug in noexcept evaluation in GCC<10, where it incorrectly requires
88 // named referenced in noexcept(noexcept()) specifiers to have been declared before being referenced if they do not
89 // depend on a template parameter.
90
91 // parasoft-begin-suppress AUTOSAR-M11_0_1-a-2 "Protected data members permitted by M11-0-1 Permit #1 v1.0.0"
92 /// @brief The underlying forward iterator
93 // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) detemplitized base class with no invariants.
94 Itr itr_;
95 // parasoft-end-suppress AUTOSAR-M11_0_1-a-2
96
97 // parasoft-begin-suppress AUTOSAR-M9_3_3-a-2 "False positive: Uses this"
98 // parasoft-begin-suppress CERT_CPP-MSC52-a-2 "False positive: does return a value"
99 // parasoft-begin-suppress CERT_C-MSC37-a-2 "False positive: does return a value"
100 // parasoft-begin-suppress AUTOSAR-A8_4_2-a-2 "False positive: does return a value"
101 /// @brief Gets the iterator needed for dereferencing in a reversed view based on forward iterators.
102 ///
103 /// @return Itr Iterator to the position _before_ the current position.
104 ARENE_NODISCARD constexpr auto itr_for_access() const noexcept(noexcept(::arene::base::prev(itr_))) -> iterator_type {
105 return ::arene::base::prev(itr_);
106 }
107 // parasoft-end-suppress AUTOSAR-A8_4_2-a-2
108 // parasoft-end-suppress CERT_C-MSC37-a-2
109 // parasoft-end-suppress CERT_CPP-MSC52-a-2
110 // parasoft-end-suppress AUTOSAR-M9_3_3-a-2
111
112 /// @brief Default ctor
113 ///
114 /// @post The iterator is constructed as if via @c Itr{}
115 constexpr reverse_iterator_base() noexcept = default;
116
117 /// @brief Copy ctor
118 /// @param other The iterator being copied
119 constexpr reverse_iterator_base(reverse_iterator_base const& other) noexcept = default;
120
121 /// @brief Move ctor
122 /// @param other The iterator being moved
123 constexpr reverse_iterator_base(reverse_iterator_base&& other) noexcept = default;
124
125 /// @brief Copy assignment
126 /// @param other The iterator being copied
127 /// @return *this
128 constexpr auto operator=(reverse_iterator_base const& other) noexcept -> reverse_iterator_base& = default;
129
130 /// @brief Move assignment
131 /// @param other The iterator being moved
132 /// @return *this
133 constexpr auto operator=(reverse_iterator_base&& other) noexcept -> reverse_iterator_base& = default;
134
135 /// @brief default destructor
136 ~reverse_iterator_base() = default;
137
138 /// @brief Construct from a non-reversed iterator
139 ///
140 /// @param iter The iterator to construct the reversed iterator from
141 /// @post The iterator points to the location of @c iter in a reversed view.
142 constexpr explicit reverse_iterator_base(Itr iter) noexcept(std::is_nothrow_copy_constructible<Itr>::value)
143 : itr_(iter) {}
144
145 public:
146 // parasoft-begin-suppress CERT_CPP-MSC52-a-2 "False positive: does return a value"
147 // parasoft-begin-suppress CERT_C-MSC37-a-2 "False positive: does return a value"
148 // parasoft-begin-suppress AUTOSAR-A8_4_2-a-2 "False positive: does return a value"
149 /// @brief Dereferences the iterator
150 ///
151 /// @return reference A reference to the element at the position of the iterator
152 ARENE_NODISCARD constexpr auto operator*() const noexcept(noexcept(
153 // weird noexcept style is needed due to a bug in GCC8 for evaluation of noexcept in constexpr.
154 *std::declval<reverse_iterator_base const&>().itr_for_access()
155 )) -> reference {
156 return *itr_for_access();
157 }
158 // parasoft-end-suppress AUTOSAR-A8_4_2-a-2
159 // parasoft-end-suppress CERT_C-MSC37-a-2
160 // parasoft-end-suppress CERT_CPP-MSC52-a-2
161
162 /// @brief Unwraps the iterator
163 ///
164 /// @return Itr A copy of the underlying iterator.
165 ARENE_NODISCARD constexpr auto base() const noexcept(std::is_nothrow_copy_constructible<Itr>::value)
166 -> iterator_type {
167 return itr_;
168 }
169};
170
171// parasoft-end-suppress AUTOSAR-A5_0_3-a
172
173} // namespace reverse_iterator_detail
174
175// parasoft-begin-suppress AUTOSAR-A5_0_3-a "This abstraction is generic and
176// does not restrict the value type of the base iterator"
177
178// parasoft-begin-suppress AUTOSAR-A10_1_1-a-2 "False positive: the ordering base class is empty"
179// parasoft-begin-suppress AUTOSAR-A13_5_1-a-2 "False positive: only const overload provided"
180/// @brief A backport of the @c constexpr @c std::reverse_iterator from C++17
181///
182/// @tparam Itr The type of the wrapped_iterator to wrap. Must satisfy @c is_bidirectional_iterator_v .
183///
184/// Specialization for when the iterator is a non-pointer type.
185template <typename Itr, bool = std::is_pointer<Itr>::value>
187 : public reverse_iterator_detail::reverse_iterator_base<Itr>
188 , generic_ordering_from_three_way_compare<reverse_iterator<Itr>> {
189 /// @brief Internal type alias for the implementation base class
190 using reviter_base = reverse_iterator_detail::reverse_iterator_base<Itr>;
191
192 /// @brief Internal type alias for the implementation base class
194
195 public:
196 // alias in typedefs
197 using typename reviter_base::difference_type;
198 using typename reviter_base::iterator_category;
199 using typename reviter_base::pointer;
200 using typename reviter_base::reference;
201 using typename reviter_base::value_type;
202
203 /// @brief Default construct
204 constexpr reverse_iterator() = default;
205
206 /// @brief Copy ctor
207 /// @param other The iterator being copied
208 constexpr reverse_iterator(reverse_iterator const& other) noexcept = default;
209
210 /// @brief Move ctor
211 /// @param other The iterator being moved
212 constexpr reverse_iterator(reverse_iterator&& other) noexcept = default;
213
214 /// @brief Copy assignment
215 /// @param other The iterator being copied
216 /// @return *this
217 constexpr auto operator=(reverse_iterator const& other) noexcept -> reverse_iterator& = default;
218
219 /// @brief Move assignment
220 /// @param other The iterator being moved
221 /// @return *this
222 constexpr auto operator=(reverse_iterator&& other) noexcept -> reverse_iterator& = default;
223
224 /// @brief default destructor
225 ~reverse_iterator() = default;
226
227 // parasoft-begin-suppress AUTOSAR-A0_1_4-a-2 "False positive: 'iter' is used"
228 /// @brief Construct from a non-reversed iterator
229 ///
230 /// @param iter The iterator to construct the reversed iterator from
231 /// @post The iterator points to the location of @c iter in a reversed view.
233 : reviter_base(iter),
234 ordering_base{} {}
235 // parasoft-end-suppress AUTOSAR-A0_1_4-a-2
236
237 /// @brief Conversion-construct from a reversed iterator of compatible type
238 ///
239 /// @tparam U The type of the iterator to convert from. Must satisfy <c>std::is_convertible<const U&, Itr></c>.
240 /// @param iter The iterator to construct the reversed iterator from
241 /// @post The iterator points to the location of @c iter in a reversed view.
242 template <
243 typename U,
247 constexpr explicit reverse_iterator(reverse_iterator<U> const& iter
248 ) noexcept(std::is_nothrow_constructible<Itr, U const&>::value&& noexcept(iter.base()))
249 : reviter_base(iter.base()),
250 ordering_base{} {}
251
252 // parasoft-begin-suppress AUTOSAR-A0_1_4-a-2 "False positive: 'iter' is used"
253 /// @brief Conversion-construct from a std::reverse_iterator
254 ///
255 /// @param iter The iterator to construct the reversed iterator from
256 /// @post The iterator points to the location of @c iter in a reversed view.
257 // NOLINTNEXTLINE(hicpp-explicit-conversions) Need implicit conversion for drop-in with std::reverse_iterator
258 constexpr reverse_iterator(reverse_iterator_detail::std_reverse_iterator<Itr> const& iter
259 ) noexcept(std::is_nothrow_constructible<reviter_base, Itr>::value&& noexcept(iter.base()))
260 : reviter_base(iter.base()),
261 ordering_base{} {}
262 // parasoft-end-suppress AUTOSAR-A0_1_4-a-2
263
264 // parasoft-begin-suppress AUTOSAR-A13_2_3-a "False positive: Not a relational operator"
265 // parasoft-begin-suppress AUTOSAR-A8_4_2-a "False positive: A value is always returned"
266 // parasoft-begin-suppress CERT_C-MSC37-a "False positive: A value is always returned"
267 // parasoft-begin-suppress CERT_CPP-MSC52-a "False positive: A value is always returned"
268 // parasoft-begin-suppress AUTOSAR-A13_5_2-a "Implicit conversion is needed for interoperability between types"
269 /// @brief Conversion operator to a std::reverse_iterator
270 ///
271 /// @return std::reverse_itr<Itr> An instance of @c std::reverse_iterator<Itr> as if constructed from @c base() .
272 // NOLINTNEXTLINE(hicpp-explicit-conversions) Need implicit conversion for drop-in with std::reverse_iterator
273 constexpr operator reverse_iterator_detail::std_reverse_iterator<Itr>() const
274 noexcept(std::is_nothrow_constructible<reverse_iterator_detail::std_reverse_iterator<Itr>, Itr>::value&& noexcept(
275 std::declval<reverse_iterator>().base()
276 )) {
277 return reverse_iterator_detail::std_reverse_iterator<Itr>{this->base()};
278 }
279 // parasoft-end-suppress AUTOSAR-A13_5_2-a
280 // parasoft-end-suppress CERT_C-MSC37-a
281 // parasoft-end-suppress CERT_CPP-MSC52-a
282 // parasoft-end-suppress AUTOSAR-A8_4_2-a
283 // parasoft-end-suppress AUTOSAR-A13_5_2-a
284
285 // parasoft-begin-suppress CERT_CPP-MSC52-a-2 "False positive: does return a value"
286 // parasoft-begin-suppress CERT_C-MSC37-a-2 "False positive: does return a value"
287 // parasoft-begin-suppress AUTOSAR-A8_4_2-a-2 "False positive: does return a value"
288 /// @brief Dereferences the iterator
289 ///
290 /// @return pointer A pointer to the element at the position of the iterator
291 ARENE_NODISCARD constexpr auto operator->() const
292 noexcept(noexcept(std::declval<reverse_iterator const&>().itr_for_access().operator->())) -> pointer {
293 return this->itr_for_access().operator->();
294 }
295 // parasoft-end-suppress AUTOSAR-A8_4_2-a-2
296 // parasoft-end-suppress CERT_C-MSC37-a-2
297 // parasoft-end-suppress CERT_CPP-MSC52-a-2
298
299 // parasoft-begin-suppress AUTOSAR-A0_1_4-a-2 "False positive: 'delta' is used"
300 // parasoft-begin-suppress CERT_CPP-MSC52-a-2 "False positive: does return a value"
301 // parasoft-begin-suppress CERT_C-MSC37-a-2 "False positive: does return a value"
302 // parasoft-begin-suppress AUTOSAR-A8_4_2-a-2 "False positive: does return a value"
303 /// @brief Index-and-dereference the iterator
304 /// @param delta The offest of the element to access
305 ///
306 /// @pre @c *this+delta is within the underlying range
307 /// @return reference A reference to the element at the position equivalent to @c *this+delta .
308 ARENE_NODISCARD constexpr auto operator[](difference_type const delta) const noexcept -> reference {
309 return *(*this + delta);
310 }
311 // parasoft-end-suppress AUTOSAR-A8_4_2-a-2
312 // parasoft-end-suppress CERT_C-MSC37-a-2
313 // parasoft-end-suppress CERT_CPP-MSC52-a-2
314 // parasoft-end-suppress AUTOSAR-A0_1_4-a-2
315
316 /// @brief Increments the iterator
317 ///
318 /// @return reverse_iterator& The iterator post-modification
319 /// @post The iterator is advanced by one position
320 constexpr auto operator++() noexcept(noexcept(--std::declval<Itr&>())) -> reverse_iterator& {
321 --(this->itr_);
322 return *this;
323 }
324
325 // parasoft-begin-suppress AUTOSAR-A3_9_1-b-2 "False positive: postincrement requires an int parameter"
326 /// @brief Increments the iterator
327 ///
328 /// @return reverse_iterator A copy of the iterator pre-modification
329 /// @post The iterator is advanced by one position
330 constexpr auto operator++(int
332 ) -> reverse_iterator {
333 auto tmp = *this;
334 ++(*this);
335 return tmp;
336 }
337 // parasoft-end-suppress AUTOSAR-A3_9_1-b-2
338
339 /// @brief Decremented the iterator
340 ///
341 /// @return reverse_iterator& The iterator post-modification
342 /// @post The iterator is decremented by one position
343 constexpr auto operator--() noexcept(noexcept(++std::declval<Itr&>())) -> reverse_iterator& {
344 ++(this->itr_);
345 return *this;
346 }
347
348 // parasoft-begin-suppress AUTOSAR-A3_9_1-b-2 "False positive: postincrement requires an int parameter"
349 /// @brief Decrements the iterator
350 ///
351 /// @return reverse_iterator A copy of the iterator pre-modification
352 /// @post The iterator is decremented by one position
353 constexpr auto operator--(int
355 ) -> reverse_iterator {
356 auto tmp = *this;
357 --(*this);
358 return tmp;
359 }
360 // parasoft-end-suppress AUTOSAR-A3_9_1-b-2
361
362 // parasoft-begin-suppress AUTOSAR-A0_1_3-a-2 "False positive: Function is namespace scope and used in other
363 // translation units"
364 // parasoft-begin-suppress AUTOSAR-A11_3_1-a-2 "Hidden friends permitted by A11-3-1 Permit #2"
365 /// @brief Add an offset to the iterator
366 ///
367 /// @param iter The iterator to add the offset to.
368 /// @param delta The offset to add.
369 /// @return reverse_iterator The iterator equivalent to advancing @c iter by @c delta positions.
370 ARENE_NODISCARD friend constexpr auto operator+(
371 reverse_iterator const& iter,
372 difference_type const delta
375 return reverse_iterator{iter.itr_ - delta};
376 }
377 // parasoft-end-suppress AUTOSAR-A0_1_3-a-2
378 // parasoft-end-suppress AUTOSAR-A11_3_1-a-2
379
380 // parasoft-begin-suppress AUTOSAR-A0_1_3-a-2 "False positive: Function is namespace scope and used in other
381 // translation units"
382 // parasoft-begin-suppress AUTOSAR-A11_3_1-a-2 "Hidden friends permitted by A11-3-1 Permit #2"
383 /// @brief Add an offset to the iterator
384 ///
385 /// @param iter The iterator to add the offset to.
386 /// @param delta The offset to add.
387 /// @return reverse_iterator The iterator equivalent to advancing @c iter by @c delta positions.
388 ARENE_NODISCARD friend constexpr auto operator+(
389 difference_type const delta,
390 reverse_iterator const& iter
393 return iter + delta;
394 }
395 // parasoft-end-suppress AUTOSAR-A0_1_3-a-2
396 // parasoft-end-suppress AUTOSAR-A11_3_1-a-2
397
398 // parasoft-begin-suppress AUTOSAR-A0_1_3-a-2 "False positive: Function is namespace scope and used in other
399 // translation units"
400 // parasoft-begin-suppress AUTOSAR-A11_3_1-a-2 "Hidden friends permitted by A11-3-1 Permit #2"
401 /// @brief Subtract an offset from the iterator
402 ///
403 /// @param iter The iterator to subtract the offset from.
404 /// @param delta The offset to subtract.
405 /// @return reverse_iterator The iterator equivalent to decrementing @c iter by @c delta positions.
406 ARENE_NODISCARD friend constexpr auto operator-(
407 reverse_iterator const& iter,
408 difference_type const delta
411 return reverse_iterator{iter.itr_ + delta};
412 }
413 // parasoft-end-suppress AUTOSAR-A0_1_3-a-2
414 // parasoft-end-suppress AUTOSAR-A11_3_1-a-2
415
416 // parasoft-begin-suppress AUTOSAR-A0_1_3-a-2 "False positive: Function is namespace scope and used in other
417 // translation units"
418 // parasoft-begin-suppress AUTOSAR-A11_3_1-a-2 "Hidden friends permitted by A11-3-1 Permit #2"
419 /// @brief Compute the difference between two iterators
420 ///
421 /// @param lhs The left-hand iterator operand.
422 /// @param rhs The right-hand iterator operand.
423 /// @return difference_type The number of positions between the two iterators.
424 ARENE_NODISCARD friend constexpr auto operator-(
425 reverse_iterator const lhs,
426 reverse_iterator const rhs
427 ) noexcept(is_nothrow_subtractable_v<Itr const&>) -> difference_type {
428 return rhs.itr_ - lhs.itr_;
429 }
430 // parasoft-end-suppress AUTOSAR-A0_1_3-a-2
431 // parasoft-end-suppress AUTOSAR-A11_3_1-a-2
432
433 /// @brief Increments the iterator by an offset
434 ///
435 /// @param delta The offset to add.
436 /// @return reverse_iterator The iterator post-modification
437 /// @post The iterator is incremented by @c delta positions.
438 constexpr auto operator+=(difference_type const delta) noexcept(noexcept(std::declval<Itr&>() -= delta))
439 -> reverse_iterator& {
440 this->itr_ -= delta;
441 return *this;
442 }
443
444 /// @brief Increments the iterator by an offset
445 ///
446 /// @param delta The offset to subtract.
447 /// @return reverse_iterator The iterator post-modification
448 /// @post The iterator is decremented by @c delta positions.
449 constexpr auto operator-=(difference_type const delta) noexcept(noexcept(std::declval<Itr&>() += delta))
450 -> reverse_iterator& {
451 this->itr_ += delta;
452 return *this;
453 }
454
455 /// @brief Compare two random access iterators for relative ordering
456 ///
457 /// @tparam U The type of the iterator to compare against. Must satisfy @c compare_three_way_supported_v<U,Itr>
458 /// @param lhs The first iterator.
459 /// @param rhs The second iterator.
460 ///
461 /// @return strong_ordering::less If @c lhs is an iterator to a position before @c rhs in the sequence.
462 /// @return strong_ordering::equal If @c lhs is an iterator to a position equivalent to @c rhs in the sequence.
463 /// @return strong_ordering::greater If @c lhs is an iterator to a position after @c rhs in the sequence.
464 template <typename U, constraints<std::enable_if_t<compare_three_way_supported_v<U, Itr>>> = nullptr>
465 ARENE_NODISCARD static constexpr auto
467 return compare_three_way{}(rhs.itr_, lhs.itr_);
468 }
469
470 /// @brief Compare two random access iterators for relative ordering
471 ///
472 /// @tparam U The type of the iterator to compare against. Must satisfy @c compare_three_way_supported_v<U,Itr>
473 /// @param lhs The first iterator.
474 /// @param rhs The second iterator.
475 ///
476 /// @return strong_ordering::less If @c lhs is an iterator to a position before @c rhs in the sequence.
477 /// @return strong_ordering::equal If @c lhs is an iterator to a position equivalent to @c rhs in the sequence.
478 /// @return strong_ordering::greater If @c lhs is an iterator to a position after @c rhs in the sequence.
479 template <typename U, constraints<std::enable_if_t<compare_three_way_supported_v<U, Itr>>> = nullptr>
480 ARENE_NODISCARD static constexpr auto
481 three_way_compare(reverse_iterator const& lhs, reverse_iterator_detail::std_reverse_iterator<U> const& rhs) noexcept
482 -> strong_ordering {
483 return compare_three_way{}(rhs.base(), lhs.itr_);
484 }
485
486 // parasoft-begin-suppress AUTOSAR-A11_3_1-a-2 "False positive: comparison operators are permitted"
487 // parasoft-begin-suppress AUTOSAR-A13_5_5-b-2 "Mixed comparisons permitted by A13-5-5 Permit #1"
488 // parasoft-begin-suppress AUTOSAR-M3_3_2-a-2 "False positive: cannot apply static here"
489 /// @brief Compare two bidirectional iterators for equality
490 ///
491 /// @tparam U The type of the iterator to compare against. Must satisfy @c is_equality_comparable<Itr,U>
492 /// @param lhs The first iterator.
493 /// @param rhs The second iterator.
494 /// @return true if the iterators point to the same position.
495 /// @return false if the iterators point to different positions.
496 template <
497 typename U,
501 ARENE_NODISCARD friend constexpr auto operator==(reverse_iterator const& lhs, reverse_iterator<U> const& rhs) noexcept
502 -> bool {
503 return lhs.itr_ == rhs.itr_;
504 }
505 // parasoft-end-suppress AUTOSAR-M3_3_2-a-2
506 // parasoft-end-suppress AUTOSAR-A11_3_1-a-2
507 // parasoft-end-suppress AUTOSAR-A13_5_5-b-2
508
509 // parasoft-begin-suppress AUTOSAR-A11_3_1-a-2 "False positive: comparison operators are permitted"
510 // parasoft-begin-suppress AUTOSAR-A13_5_5-b-2 "Mixed comparisons permitted by A13-5-5 Permit #1"
511 /// @brief Compare two bidirectional iterators for equality
512 ///
513 /// @tparam U The type of the iterator to compare against. Must satisfy @c is_equality_comparable<Itr,U>
514 /// @param lhs The first iterator.
515 /// @param rhs The second iterator.
516 /// @return true if the iterators point to the same position.
517 /// @return false if the iterators point to different positions.
518 template <
519 typename U,
523 ARENE_NODISCARD friend constexpr auto operator==(
524 reverse_iterator const& lhs,
525 reverse_iterator_detail::std_reverse_iterator<U> const& rhs
526 ) noexcept(noexcept(std::declval<Itr>() == std::declval<U>()) && noexcept(rhs.base())) -> bool {
527 return lhs.itr_ == rhs.base();
528 }
529 // parasoft-end-suppress AUTOSAR-A11_3_1-a-2
530 // parasoft-end-suppress AUTOSAR-A13_5_5-b-2
531
532 // parasoft-begin-suppress AUTOSAR-A13_5_5-b-2 "Mixed comparisons permitted by A13-5-5 Permit #1"
533 // parasoft-begin-suppress AUTOSAR-A11_3_1-a-2 "False positive: comparison operators are permitted"
534 /// @brief Compare two bidirectional iterators for inequality
535 ///
536 /// @tparam U The type of the iterator to compare against. Must satisfy @c is_equality_comparable<Itr,U>
537 /// @param lhs The first iterator.
538 /// @param rhs The second iterator.
539 /// @return true if the iterators point to the different positions.
540 /// @return false if the iterators point to the same position.
541 template <
542 typename U,
546 ARENE_NODISCARD friend constexpr auto operator!=(reverse_iterator const& lhs, reverse_iterator<U> const& rhs) noexcept
547 -> bool {
548 return lhs.itr_ != rhs.itr_;
549 }
550 // parasoft-end-suppress AUTOSAR-A11_3_1-a-2
551 // parasoft-end-suppress AUTOSAR-A13_5_5-b-2
552
553 // parasoft-begin-suppress AUTOSAR-A13_5_5-b-2 "Mixed comparisons permitted by A13-5-5 Permit #1"
554 // parasoft-begin-suppress AUTOSAR-A11_3_1-a-2 "False positive: comparison operators are permitted"
555 /// @brief Compare two bidirectional iterators for inequality
556 ///
557 /// @tparam U The type of the iterator to compare against. Must satisfy @c is_equality_comparable<Itr,U>
558 /// @param lhs The first iterator.
559 /// @param rhs The second iterator.
560 /// @return true if the iterators point to the different positions.
561 /// @return false if the iterators point to the same position.
562 template <
563 typename U,
567 ARENE_NODISCARD friend constexpr auto
568 operator!=(reverse_iterator const& lhs, reverse_iterator_detail::std_reverse_iterator<U> const& rhs) noexcept
569 -> bool {
570 return lhs.itr_ != rhs.base();
571 }
572 // parasoft-end-suppress AUTOSAR-A11_3_1-a-2
573 // parasoft-end-suppress AUTOSAR-A13_5_5-b-2
574};
575// parasoft-end-suppress AUTOSAR-A13_5_1-a-2
576// parasoft-end-suppress AUTOSAR-A10_1_1-a-2
577
578// parasoft-begin-suppress AUTOSAR-A10_1_1-a-2 "False positive: the ordering base class is empty"
579// parasoft-begin-suppress AUTOSAR-A13_5_1-a-2 "False positive: only const overload provided"
580/// @brief A backport of the @c constexpr @c std::reverse_iterator from C++17
581///
582/// @tparam Itr The type of the wrapped_iterator to wrap. Must satisfy @c is_bidirectional_iterator_v .
583///
584/// Specialization for when the iterator is a pointer type.
585template <typename Itr>
586class reverse_iterator<Itr, true> final
587 : public reverse_iterator_detail::reverse_iterator_base<Itr>
588 , generic_ordering_from_three_way_compare<reverse_iterator<Itr>> {
589 /// @brief Internal type alias for the implementation base class
590 using reviter_base = reverse_iterator_detail::reverse_iterator_base<Itr>;
591 /// @brief Internal type alias for the implementation base class
593
594 public:
595 // alias in typedefs
596 using typename reviter_base::difference_type;
597 using typename reviter_base::iterator_category;
598 using typename reviter_base::pointer;
599 using typename reviter_base::reference;
600 using typename reviter_base::value_type;
601
602 /// @brief Default construct
603 constexpr reverse_iterator() = default;
604
605 /// @brief Copy ctor
606 /// @param other The iterator being copied
607 constexpr reverse_iterator(reverse_iterator const& other) noexcept = default;
608
609 /// @brief Move ctor
610 /// @param other The iterator being moved
611 constexpr reverse_iterator(reverse_iterator&& other) noexcept = default;
612
613 /// @brief Copy assignment
614 /// @param other The iterator being copied
615 /// @return *this
616 constexpr auto operator=(reverse_iterator const& other) noexcept -> reverse_iterator& = default;
617
618 /// @brief Move assignment
619 /// @param other The iterator being moved
620 /// @return *this
621 constexpr auto operator=(reverse_iterator&& other) noexcept -> reverse_iterator& = default;
622
623 /// @brief default destructor
624 ~reverse_iterator() = default;
625
626 /// @brief Construct from a non-reversed iterator
627 ///
628 /// @param iter The iterator to construct the reversed iterator from
629 /// @post The iterator points to the location of @c iter in a reversed view.
631 : reviter_base(iter),
632 ordering_base{} {}
633
634 /// @brief Conversion-construct from a reversed iterator of compatible type
635 ///
636 /// @tparam U The type of the iterator to convert from. Must satisfy <c>std::is_convertible<const U&, Itr></c>.
637 /// @param iter The iterator to construct the reversed iterator from
638 /// @post The iterator points to the location of @c iter in a reversed view.
639 template <
640 typename U,
644 constexpr explicit reverse_iterator(reverse_iterator<U> const& iter
645 ) noexcept(std::is_nothrow_constructible<Itr, U const&>::value&& noexcept(iter.base()))
646 : reviter_base(iter.base()),
647 ordering_base{} {}
648
649 /// @brief Conversion-construct from a std::reverse_iterator
650 ///
651 /// @param iter The iterator to construct the reversed iterator from
652 /// @post The iterator points to the location of @c iter in a reversed view.
653 // NOLINTNEXTLINE(hicpp-explicit-conversions) Need implicit conversion for drop-in with std::reverse_iterator
654 constexpr reverse_iterator(reverse_iterator_detail::std_reverse_iterator<Itr> const& iter
655 ) noexcept(std::is_nothrow_constructible<reviter_base, Itr>::value&& noexcept(iter.base()))
656 : reviter_base(iter.base()),
657 ordering_base{} {}
658
659 // parasoft-begin-suppress AUTOSAR-A13_2_3-a "False positive: Not a relational operator"
660 // parasoft-begin-suppress AUTOSAR-A13_5_2-a "Implicit conversion is needed for interoperability between types"
661 /// @brief Conversion operator to a std::reverse_iterator
662 ///
663 /// @return std::reverse_itr<Itr> An instance of @c std::reverse_iterator<Itr> as if constructed from @c base() .
664 // NOLINTNEXTLINE(hicpp-explicit-conversions) Need implicit conversion for drop-in with std::reverse_iterator
665 constexpr operator reverse_iterator_detail::std_reverse_iterator<Itr>() const
666 noexcept(std::is_nothrow_constructible<reverse_iterator_detail::std_reverse_iterator<Itr>, Itr>::value&& noexcept(
667 std::declval<reverse_iterator>().base()
668 )) {
669 return reverse_iterator_detail::std_reverse_iterator<Itr>{this->base()};
670 }
671 // parasoft-end-suppress AUTOSAR-A13_2_3-a
672 // parasoft-end-suppress AUTOSAR-A13_5_2-a
673
674 /// @brief Dereferences the iterator
675 ///
676 /// @return pointer A pointer to the element at the position of the iterator
677 ARENE_NODISCARD constexpr auto operator->() const noexcept -> pointer { return this->itr_for_access(); }
678
679 /// @brief Index-and-dereference the iterator
680 ///
681 /// @param delta The index at which to dereference the iterator
682 ///
683 /// @return reference A reference to the element at the position equivalent to @c *this+delta .
684
685 ARENE_NODISCARD constexpr auto operator[](difference_type const delta) const noexcept -> reference {
686 return *(*this + delta);
687 }
688
689 /// @brief Increments the iterator
690 ///
691 /// @return reverse_iterator& The iterator post-modification
692 /// @post The iterator is advanced by one position
693 constexpr auto operator++() noexcept -> reverse_iterator& {
694 *this += 1;
695 return *this;
696 }
697
698 // parasoft-begin-suppress AUTOSAR-A3_9_1-b-2 "False positive: postincrement requires an int parameter"
699 /// @brief Increments the iterator
700 ///
701 /// @return reverse_iterator A copy of the iterator pre-modification
702 /// @post The iterator is advanced by one position
703 constexpr auto operator++(int) noexcept -> reverse_iterator {
704 auto tmp = *this;
705 ++(*this);
706 return tmp;
707 }
708 // parasoft-end-suppress AUTOSAR-A3_9_1-b-2
709
710 /// @brief Decremented the iterator
711 ///
712 /// @return reverse_iterator& The iterator post-modification
713 /// @post The iterator is decremented by one position
714 constexpr auto operator--() noexcept -> reverse_iterator& {
715 *this -= 1;
716 return *this;
717 }
718
719 // parasoft-begin-suppress AUTOSAR-A3_9_1-b-2 "False positive: postincrement requires an int parameter"
720 /// @brief Decrements the iterator
721 ///
722 /// @return reverse_iterator A copy of the iterator pre-modification
723 /// @post The iterator is decremented by one position
724 constexpr auto operator--(int) noexcept -> reverse_iterator {
725 auto tmp = *this;
726 --(*this);
727 return tmp;
728 }
729 // parasoft-end-suppress AUTOSAR-A3_9_1-b-2
730
731 // parasoft-begin-suppress AUTOSAR-A0_1_3-a-2 "False positive: Function is namespace scope and used in other
732 // translation units"
733 // parasoft-begin-suppress AUTOSAR-A11_3_1-a-2 "Hidden friends permitted by A11-3-1 Permit #2"
734 // parasoft-begin-suppress AUTOSAR-A7_1_1-a-2 "False positive: iter is modified"
735 /// @brief Add an offset to the iterator
736 ///
737 /// @param iter The iterator to add the offset to.
738 /// @param delta The offset to add.
739 /// @return reverse_iterator The iterator equivalent to advancing @c iter by @c delta positions.
740 ARENE_NODISCARD friend constexpr auto operator+(reverse_iterator iter, difference_type const delta) noexcept
742 iter += delta;
743 return iter;
744 }
745 // parasoft-end-suppress AUTOSAR-A0_1_3-a-2
746 // parasoft-end-suppress AUTOSAR-A7_1_1-a-2
747 // parasoft-end-suppress AUTOSAR-A11_3_1-a-2
748
749 // parasoft-begin-suppress AUTOSAR-A0_1_3-a-2 "False positive: Function is namespace scope and used in other
750 // translation units"
751 // parasoft-begin-suppress AUTOSAR-A11_3_1-a-2 "Hidden friends permitted by A11-3-1 Permit #2"
752 /// @brief Add an offset to the iterator
753 ///
754 /// @param iter The iterator to add the offset to.
755 /// @param delta The offset to add.
756 /// @return reverse_iterator The iterator equivalent to advancing @c iter by @c delta positions.
757 ARENE_NODISCARD friend constexpr auto operator+(difference_type const delta, reverse_iterator const& iter) noexcept
759 return iter + delta;
760 }
761 // parasoft-end-suppress AUTOSAR-A0_1_3-a-2
762 // parasoft-end-suppress AUTOSAR-A11_3_1-a-2
763
764 // parasoft-begin-suppress AUTOSAR-A0_1_3-a-2 "False positive: Function is namespace scope and used in other
765 // translation units"
766 // parasoft-begin-suppress AUTOSAR-A7_1_1-a-2 "False positive: iter is modified"
767 // parasoft-begin-suppress AUTOSAR-A11_3_1-a-2 "Hidden friends permitted by A11-3-1 Permit #2"
768 /// @brief Subtract an offset from the iterator
769 ///
770 /// @param iter The iterator to subtract the offset from.
771 /// @param delta The offset to subtract.
772 /// @return reverse_iterator The iterator equivalent to decrementing @c iter by @c delta positions.
773 ARENE_NODISCARD friend constexpr auto operator-(reverse_iterator iter, difference_type const delta) noexcept
775 iter -= delta;
776 return iter;
777 }
778 // parasoft-end-suppress AUTOSAR-A0_1_3-a-2
779 // parasoft-end-suppress AUTOSAR-A7_1_1-a-2
780 // parasoft-end-suppress AUTOSAR-A11_3_1-a-2
781
782 // parasoft-begin-suppress AUTOSAR-A0_1_3-a-2 "False positive: Function is namespace scope and used in other
783 // translation units"
784 // parasoft-begin-suppress AUTOSAR-A11_3_1-a-2 "Hidden friends permitted by A11-3-1 Permit #2"
785 /// @brief Compute the difference between two iterators
786 ///
787 /// @param lhs The left-hand iterator operand.
788 /// @param rhs The right-hand iterator operand.
789 /// @return difference_type The number of positions between the two iterators.
790 ARENE_NODISCARD friend constexpr auto operator-(reverse_iterator const lhs, reverse_iterator const rhs) noexcept
791 -> difference_type {
792 return ::arene::base::distance(lhs.itr_, rhs.itr_);
793 }
794 // parasoft-end-suppress AUTOSAR-A0_1_3-a-2
795
796 // parasoft-end-suppress AUTOSAR-A11_3_1-a-2
797 /// @brief Increments the iterator by an offset
798 ///
799 /// @param delta The offset to add.
800 /// @return reverse_iterator The iterator post-modification
801 /// @post The iterator is incremented by @c delta positions.
802 constexpr auto operator+=(difference_type const delta) noexcept -> reverse_iterator& {
803 this->itr_ = ::arene::base::prev(this->itr_, delta);
804 return *this;
805 }
806
807 /// @brief Increments the iterator by an offset
808 ///
809 /// @param delta The offset to subtract.
810 /// @return reverse_iterator The iterator post-modification
811 /// @post The iterator is decremented by @c delta positions.
812 constexpr auto operator-=(difference_type const delta) noexcept -> reverse_iterator& {
813 this->itr_ = ::arene::base::next(this->itr_, delta);
814 return *this;
815 }
816
817 /// @brief Compare two random access iterators for relative ordering
818 ///
819 /// @tparam U The type of the iterator to compare against. Must satisfy @c compare_three_way_supported_v<U,Itr>
820 /// @param lhs The first iterator.
821 /// @param rhs The second iterator.
822 ///
823 /// @return strong_ordering::less If @c lhs is an iterator to a position before @c rhs in the sequence.
824 /// @return strong_ordering::equal If @c lhs is an iterator to a position equivalent to @c rhs in the sequence.
825 /// @return strong_ordering::greater If @c lhs is an iterator to a position after @c rhs in the sequence.
826 template <typename U, constraints<std::enable_if_t<compare_three_way_supported_v<U, Itr>>> = nullptr>
827 ARENE_NODISCARD static constexpr auto
829 return compare_three_way{}(rhs.itr_, lhs.itr_);
830 }
831
832 /// @brief Compare two random access iterators for relative ordering
833 ///
834 /// @tparam U The type of the iterator to compare against. Must satisfy @c compare_three_way_supported_v<U,Itr>
835 /// @param lhs The first iterator.
836 /// @param rhs The second iterator.
837 ///
838 /// @return strong_ordering::less If @c lhs is an iterator to a position before @c rhs in the sequence.
839 /// @return strong_ordering::equal If @c lhs is an iterator to a position equivalent to @c rhs in the sequence.
840 /// @return strong_ordering::greater If @c lhs is an iterator to a position after @c rhs in the sequence.
841 template <typename U, constraints<std::enable_if_t<compare_three_way_supported_v<U, Itr>>> = nullptr>
842 ARENE_NODISCARD static constexpr auto
843 three_way_compare(reverse_iterator const& lhs, reverse_iterator_detail::std_reverse_iterator<U> const& rhs) noexcept
844 -> strong_ordering {
845 return compare_three_way{}(rhs.base(), lhs.itr_);
846 }
847};
848// parasoft-end-suppress AUTOSAR-A13_5_1-a-2
849// parasoft-end-suppress AUTOSAR-A10_1_1-a-2
850
851// parasoft-end-suppress AUTOSAR-A5_0_3-a
852
853/// @brief Factory function for creating a @c reverse_iterator with deduced template arguments pre C++17.
854///
855/// @tparam Itr The type of the wrapped_iterator to wrap. Must satisfy @c is_bidirectional_iterator_v .
856/// @param iter The iterator to construct from.
857/// @return reverse_iterator<Itr> Equivalent to @c reverse_iterator<Itr>{std::forward<Itr>(iter)} .
858template <typename Itr, constraints<std::enable_if_t<is_bidirectional_iterator_v<Itr>>> = nullptr>
859constexpr auto make_reverse_iterator(Itr&& iter
862}
863
864} // namespace base
865} // namespace arene
866
867#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_ITERATOR_REVERSE_ITERATOR_HPP_
static ARENE_NODISCARD constexpr auto three_way_compare(reverse_iterator const &lhs, reverse_iterator< U > const &rhs) noexcept -> strong_ordering
Compare two random access iterators for relative ordering.
Definition reverse_iterator.hpp:828
constexpr reverse_iterator()=default
Default construct.
constexpr auto operator=(reverse_iterator const &other) noexcept -> reverse_iterator &=default
Copy assignment.
ARENE_NODISCARD friend constexpr auto operator-(reverse_iterator iter, difference_type const delta) noexcept -> reverse_iterator
Subtract an offset from the iterator.
Definition reverse_iterator.hpp:773
constexpr auto operator--() noexcept -> reverse_iterator &
Decremented the iterator.
Definition reverse_iterator.hpp:714
constexpr reverse_iterator(reverse_iterator_detail::std_reverse_iterator< Itr > const &iter) noexcept(std::is_nothrow_constructible< reviter_base, Itr >::value &&noexcept(iter.base()))
Conversion-construct from a std::reverse_iterator.
Definition reverse_iterator.hpp:654
ARENE_NODISCARD friend constexpr auto operator+(reverse_iterator iter, difference_type const delta) noexcept -> reverse_iterator
Add an offset to the iterator.
Definition reverse_iterator.hpp:740
ARENE_NODISCARD constexpr auto operator[](difference_type const delta) const noexcept -> reference
Index-and-dereference the iterator.
Definition reverse_iterator.hpp:685
static ARENE_NODISCARD constexpr auto three_way_compare(reverse_iterator const &lhs, reverse_iterator_detail::std_reverse_iterator< U > const &rhs) noexcept -> strong_ordering
Compare two random access iterators for relative ordering.
Definition reverse_iterator.hpp:843
constexpr auto operator=(reverse_iterator &&other) noexcept -> reverse_iterator &=default
Move assignment.
ARENE_NODISCARD friend constexpr auto operator+(difference_type const delta, reverse_iterator const &iter) noexcept -> reverse_iterator
Add an offset to the iterator.
Definition reverse_iterator.hpp:757
ARENE_NODISCARD constexpr auto operator->() const noexcept -> pointer
Dereferences the iterator.
Definition reverse_iterator.hpp:677
constexpr auto operator++(int) noexcept -> reverse_iterator
Increments the iterator.
Definition reverse_iterator.hpp:703
constexpr auto operator+=(difference_type const delta) noexcept -> reverse_iterator &
Increments the iterator by an offset.
Definition reverse_iterator.hpp:802
constexpr reverse_iterator(reverse_iterator< U > const &iter) noexcept(std::is_nothrow_constructible< Itr, U const & >::value &&noexcept(iter.base()))
Conversion-construct from a reversed iterator of compatible type.
Definition reverse_iterator.hpp:644
constexpr reverse_iterator(reverse_iterator const &other) noexcept=default
Copy ctor.
constexpr reverse_iterator(reverse_iterator &&other) noexcept=default
Move ctor.
constexpr reverse_iterator(Itr iter) noexcept(std::is_nothrow_copy_constructible< Itr >::value)
Construct from a non-reversed iterator.
Definition reverse_iterator.hpp:630
ARENE_NODISCARD friend constexpr auto operator-(reverse_iterator const lhs, reverse_iterator const rhs) noexcept -> difference_type
Compute the difference between two iterators.
Definition reverse_iterator.hpp:790
~reverse_iterator()=default
default destructor
constexpr auto operator--(int) noexcept -> reverse_iterator
Decrements the iterator.
Definition reverse_iterator.hpp:724
constexpr auto operator++() noexcept -> reverse_iterator &
Increments the iterator.
Definition reverse_iterator.hpp:693
constexpr auto operator-=(difference_type const delta) noexcept -> reverse_iterator &
Increments the iterator by an offset.
Definition reverse_iterator.hpp:812
A backport of the constexpr std::reverse_iterator from C++17.
Definition reverse_iterator.hpp:188
constexpr reverse_iterator()=default
Default construct.
static ARENE_NODISCARD constexpr auto three_way_compare(reverse_iterator const &lhs, reverse_iterator< U > const &rhs) noexcept -> strong_ordering
Compare two random access iterators for relative ordering.
Definition reverse_iterator.hpp:466
constexpr reverse_iterator(Itr iter) noexcept(std::is_nothrow_copy_constructible< Itr >::value)
Construct from a non-reversed iterator.
Definition reverse_iterator.hpp:232
ARENE_NODISCARD friend constexpr auto operator-(reverse_iterator const lhs, reverse_iterator const rhs) noexcept(is_nothrow_subtractable_v< Itr const & >) -> difference_type
Compute the difference between two iterators.
Definition reverse_iterator.hpp:424
ARENE_NODISCARD friend constexpr auto operator-(reverse_iterator const &iter, difference_type const delta) noexcept(std::is_nothrow_copy_constructible< Itr >::value &&is_nothrow_addable_v< Itr const &, difference_type const >) -> reverse_iterator
Subtract an offset from the iterator.
Definition reverse_iterator.hpp:406
constexpr reverse_iterator(reverse_iterator_detail::std_reverse_iterator< Itr > const &iter) noexcept(std::is_nothrow_constructible< reviter_base, Itr >::value &&noexcept(iter.base()))
Conversion-construct from a std::reverse_iterator.
Definition reverse_iterator.hpp:258
ARENE_NODISCARD friend constexpr auto operator==(reverse_iterator const &lhs, reverse_iterator_detail::std_reverse_iterator< U > const &rhs) noexcept(noexcept(std::declval< Itr >()==std::declval< U >()) &&noexcept(rhs.base())) -> bool
Compare two bidirectional iterators for equality.
Definition reverse_iterator.hpp:523
constexpr reverse_iterator(reverse_iterator< U > const &iter) noexcept(std::is_nothrow_constructible< Itr, U const & >::value &&noexcept(iter.base()))
Conversion-construct from a reversed iterator of compatible type.
Definition reverse_iterator.hpp:247
constexpr auto operator=(reverse_iterator const &other) noexcept -> reverse_iterator &=default
Copy assignment.
constexpr auto operator++(int) noexcept(std::is_nothrow_copy_constructible< reverse_iterator >::value &&noexcept(++std::declval< reverse_iterator & >())) -> reverse_iterator
Increments the iterator.
Definition reverse_iterator.hpp:330
static ARENE_NODISCARD constexpr auto three_way_compare(reverse_iterator const &lhs, reverse_iterator_detail::std_reverse_iterator< U > const &rhs) noexcept -> strong_ordering
Compare two random access iterators for relative ordering.
Definition reverse_iterator.hpp:481
ARENE_NODISCARD friend constexpr auto operator+(reverse_iterator const &iter, difference_type const delta) noexcept(std::is_nothrow_copy_constructible< Itr >::value &&is_nothrow_subtractable_v< Itr const &, difference_type const >) -> reverse_iterator
Add an offset to the iterator.
Definition reverse_iterator.hpp:370
ARENE_NODISCARD constexpr auto operator[](difference_type const delta) const noexcept -> reference
Index-and-dereference the iterator.
Definition reverse_iterator.hpp:308
constexpr auto operator--(int) noexcept(std::is_nothrow_copy_constructible< reverse_iterator >::value &&noexcept(--std::declval< reverse_iterator & >())) -> reverse_iterator
Decrements the iterator.
Definition reverse_iterator.hpp:353
constexpr auto operator--() noexcept(noexcept(++std::declval< Itr & >())) -> reverse_iterator &
Decremented the iterator.
Definition reverse_iterator.hpp:343
ARENE_NODISCARD friend constexpr auto operator!=(reverse_iterator const &lhs, reverse_iterator_detail::std_reverse_iterator< U > const &rhs) noexcept -> bool
Compare two bidirectional iterators for inequality.
Definition reverse_iterator.hpp:568
ARENE_NODISCARD friend constexpr auto operator+(difference_type const delta, reverse_iterator const &iter) noexcept(std::is_nothrow_copy_constructible< Itr >::value &&is_nothrow_subtractable_v< Itr const &, difference_type const >) -> reverse_iterator
Add an offset to the iterator.
Definition reverse_iterator.hpp:388
ARENE_NODISCARD friend constexpr auto operator!=(reverse_iterator const &lhs, reverse_iterator< U > const &rhs) noexcept -> bool
Compare two bidirectional iterators for inequality.
Definition reverse_iterator.hpp:546
constexpr auto operator+=(difference_type const delta) noexcept(noexcept(std::declval< Itr & >() -=delta)) -> reverse_iterator &
Increments the iterator by an offset.
Definition reverse_iterator.hpp:438
ARENE_NODISCARD friend constexpr auto operator==(reverse_iterator const &lhs, reverse_iterator< U > const &rhs) noexcept -> bool
Compare two bidirectional iterators for equality.
Definition reverse_iterator.hpp:501
constexpr auto operator++() noexcept(noexcept(--std::declval< Itr & >())) -> reverse_iterator &
Increments the iterator.
Definition reverse_iterator.hpp:320
constexpr reverse_iterator(reverse_iterator &&other) noexcept=default
Move ctor.
constexpr auto operator-=(difference_type const delta) noexcept(noexcept(std::declval< Itr & >()+=delta)) -> reverse_iterator &
Increments the iterator by an offset.
Definition reverse_iterator.hpp:449
~reverse_iterator()=default
default destructor
constexpr auto operator=(reverse_iterator &&other) noexcept -> reverse_iterator &=default
Move assignment.
constexpr reverse_iterator(reverse_iterator const &other) noexcept=default
Copy ctor.
ARENE_NODISCARD constexpr auto operator->() const noexcept(noexcept(std::declval< reverse_iterator const & >().itr_for_access().operator->())) -> pointer
Dereferences the iterator.
Definition reverse_iterator.hpp:291
static constexpr value_type value
Definition integral_constant.hpp:34
Type trait to detect if a type is constructible from arguments of the specified types and is noexcept...
Definition is_constructible.hpp:84
Definition accumulate.hpp:37
ARENE_NODISCARD constexpr auto next(Iterator itr, typename std::iterator_traits< Iterator >::difference_type steps=1) noexcept(noexcept(::arene::base::advance(itr, steps))) -> Iterator
Produces the Nth successor (or predecessor if steps is negative) of an iterator.
Definition next.hpp:38
strong_ordering_detail::strong_ordering strong_ordering
The enumeration specifying the result of an ordering comparison.
Definition strong_ordering.hpp:147
three_way_compare_detail::compare_three_way compare_three_way
Function object that does a three-way comparison between operands, equivalent to std::compare_three_w...
Definition compare_three_way.hpp:214
constexpr bool is_nothrow_addable_v
Check if instances of Lhs can be added to instances of Rhs without throwing an exception....
constexpr bool is_nothrow_subtractable_v
Check if instances of Rhs can be subtracted from an instance of Lhs without throwing an exception....
constexpr auto make_reverse_iterator(Itr &&iter) noexcept(noexcept(std::is_nothrow_constructible< reverse_iterator< Itr >, Itr && >::value)) -> reverse_iterator< Itr >
Factory function for creating a reverse_iterator with deduced template arguments pre C++17.
Definition reverse_iterator.hpp:859
typename constraints_impl::constraints< EnableIfs... >::type constraints
Helper used to express template constraints in a consistent way using std::enable_if_t.
Definition constraints.hpp:51
constexpr bool is_bidirectional_iterator_v
Definition iterator_category_traits.hpp:312
ARENE_NODISCARD constexpr auto prev(Iterator itr, typename std::iterator_traits< Iterator >::difference_type steps=1) noexcept(noexcept(::arene::base::advance(itr, -steps))) -> Iterator
Produces the Nth predecessor (or successor if steps is negative) of an iterator.
Definition prev.hpp:44
Definition accumulate.hpp:36
STL namespace.
typename enable_if< Condition, Type >::type enable_if_t
Type alias to support constraining templates. Is an alias for the specified type if the Condition is ...
Definition enable_if.hpp:41
auto declval() noexcept -> T &&
A dummy function that is declared but not defined, with a user-specified return type,...
constexpr auto forward(remove_reference_t< T > &value) noexcept -> T &&
Cast a value to an rvalue if T is an rvalue or rvalue reference, otherwise forward an lvalue referenc...
Definition forward.hpp:24
#define ARENE_NODISCARD
An alias for [[nodiscard]] , or a no-op if the attribute is not supported.
Definition nodiscard.hpp:26