Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
prev.hpp
Go to the documentation of this file.
1// Copyright 2024, Toyota Motor Corporation
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_ITERATOR_PREV_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_ITERATOR_PREV_HPP_
7
8// IWYU pragma: private, include "arene/base/iterator.hpp"
9// IWYU pragma: friend "(arene/base(?!/tests)|stdlib/include/stdlib_detail)/.*"
10
11// parasoft-begin-suppress AUTOSAR-A16_2_2-a-2 "Arene Base aggregate headers permitted by A16-2-2 Permit #1"
12#include "arene/base/compiler_support/attributes.hpp"
13#include "arene/base/constraints/constraints.hpp"
14#include "arene/base/contracts/contract.hpp"
15#include "arene/base/iterator/advance.hpp"
16#include "arene/base/stdlib_choice/enable_if.hpp"
17#include "arene/base/stdlib_choice/iterator_traits.hpp"
18#include "arene/base/stdlib_choice/numeric_limits.hpp"
19#include "arene/base/type_traits/iterator_category_traits.hpp"
20// parasoft-end-suppress AUTOSAR-A16_2_2-a-2
21
22// parasoft-begin-suppress CERT_C-PRE31-c-3 "False Positive: numeric_limits::min() is constexpr and has no side effects,
23// exception PRE31-C-EX1"
24
25// parasoft-begin-suppress AUTOSAR-A5_0_3-a "This abstraction is generic and
26// does not restrict the value type of the iterator"
27
28namespace arene {
29namespace base {
30
31///
32/// @brief Produces the Nth predecessor (or successor if @c steps is negative) of an iterator.
33///
34/// @tparam Iterator The iterator to advance. Does not participate in overload resolution unless @c Iterator is at
35/// least a bidirectional iterator.
36/// @param itr The iterator to advance
37/// @param steps The number of steps to advance the iterator by
38/// @pre If incrementing or decrementing @c itr @c steps times results in attempting to produce an invalid iterator
39/// such as past-the-end or before-the-begin, behavior is undefined.
40/// @pre @c steps is not @c std::numeric_limits<difference_type>::min() , else behavior is undefined.
41/// @return The iterator produced by incrementing/decrementing @c itr @c steps times.
42///
44ARENE_NODISCARD constexpr auto prev( // CODEQLFP(DCL51-CPP)
47) noexcept(noexcept(::arene::base::advance(itr, -steps))) -> Iterator { // CODEQLFP(EXP52-CPP)
49 ::arene::base::advance(itr, -steps);
50 return itr;
51}
52
53} // namespace base
54} // namespace arene
55
56#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_ITERATOR_PREV_HPP_
Definition array_exceptions_disabled.cpp:11
Copyright 2026, Toyota Motor Corporation.
Definition array_exceptions_disabled.cpp:10