Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
borrowed_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#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_RANGES_BORROWED_ITERATOR_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_RANGES_BORROWED_ITERATOR_HPP_
7
8// IWYU pragma: private, include "arene/base/ranges.hpp"
9// IWYU pragma: friend "(arene/base(?!/tests)|stdlib/include/stdlib_detail)/.*"
10
15
16namespace arene {
17namespace base {
18namespace ranges {
19
20namespace borrowed_iterator_detail {
21
22/// @brief Alias template to @c dangling for the fixed result of the non-borrowed branch.
23/// @tparam Rng The unused type parameter required by @c conditional_apply_t .
24template <typename Rng>
25using always_dangling = ::arene::base::ranges::dangling;
26
27} // namespace borrowed_iterator_detail
28
29/// @brief A type alias conditionally selects between a ranges iterator or @c arene::base::dangling .
30/// @tparam Rng The range type for which to obtain the borrowed iterator type.
31///
32/// If @c Rng satisfies @c arene::base::is_borrowed_range_v<Rng>, the type alias resolves to
33/// @c arene::base::ranges::iterator_t<Rng> . Otherwise, it resolves to @c arene::base::ranges::dangling . This can be
34/// used to safely create range algorithms which should match all range types, but only return valid content if the
35/// input is a borrowed range.
36template <typename Rng>
38 conditional_apply_t<is_borrowed_range_v<Rng>, iterator_t, borrowed_iterator_detail::always_dangling, Rng>;
39
40} // namespace ranges
41} // namespace base
42} // namespace arene
43
44#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_RANGES_BORROWED_ITERATOR_HPP_
Definition external_vector.hpp:803
typedef iterator_t
The type of the iterator for a given range.
Definition begin_end.hpp:186
conditional_apply_t< is_borrowed_range_v< Rng >, iterator_t, borrowed_iterator_detail::always_dangling, Rng > borrowed_iterator_t
A type alias conditionally selects between a ranges iterator or arene::base::dangling .
Definition borrowed_iterator.hpp:37
Definition accumulate.hpp:37
typename static_if< B >::template then_apply_else_apply< OnTrue, OnFalse, Args... > conditional_apply_t
lazily apply one of two template aliases based on a boolean condition
Definition conditional.hpp:73
Definition accumulate.hpp:36