Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
next.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_NEXT_HPP_
6
#
define
INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_ITERATOR_NEXT_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/iterator/advance.hpp"
15
#
include
"arene/base/stdlib_choice/enable_if.hpp"
16
#
include
"arene/base/stdlib_choice/iterator_traits.hpp"
17
#
include
"arene/base/type_traits/iterator_category_traits.hpp"
18
// parasoft-end-suppress AUTOSAR-A16_2_2-a-2
19
20
namespace
arene
{
21
namespace
base
{
22
23
// parasoft-begin-suppress AUTOSAR-M3_3_2-a-2 "False positive: inline function used in multiple translation units"
24
///
25
/// @brief Produces the Nth successor (or predecessor if @c steps is negative) of an iterator.
26
///
27
/// @tparam Iterator The iterator to advance. Does not participate in overload resolution unless @c Iterator is at
28
/// least an input iterator.
29
/// @param itr The iterator to advance
30
/// @param steps The number of steps to advance the iterator by
31
/// @pre If incrementing or decrementing @c itr @c steps times results in attempting to produce an invalid iterator
32
/// such as past-the-end or before-the-begin, behavior is undefined.
33
/// @pre If @c Iterator is an input iterator, @c steps is not negative, else @c ARENE_PRECONDITION violation.
34
/// @return The iterator produced by incrementing/decrementing @c itr @c steps times.
35
///
36
template
<
typename
Iterator
,
constraints
<
std
::
enable_if_t
<
is_input_iterator_v
<
Iterator
>>> =
nullptr
>
37
ARENE_NODISCARD
constexpr
auto
next
(
// CODEQLFP(DCL51-CPP)
38
Iterator
itr
,
39
typename
std
::
iterator_traits
<
Iterator
>::
difference_type
steps
= 1
40
)
noexcept
(
noexcept
(::
arene
::
base
::
advance
(
itr
,
steps
))) ->
Iterator
{
// CODEQLFP(EXP52-CPP)
41
::
arene
::
base
::
advance
(
itr
,
steps
);
42
return
itr
;
43
}
44
// parasoft-end-suppress AUTOSAR-M3_3_2-a-2
45
46
}
// namespace base
47
}
// namespace arene
48
49
#
endif
// INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_ITERATOR_NEXT_HPP_
arene::base
Definition
array_exceptions_disabled.cpp:11
arene
Copyright 2026, Toyota Motor Corporation.
Definition
array_exceptions_disabled.cpp:10
arene
base
iterator
next.hpp
Generated by
1.13.2