Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
is_borrowed_range.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_IS_BORROWED_RANGE_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_RANGES_IS_BORROWED_RANGE_HPP_
7
8// IWYU pragma: private, include "arene/base/ranges.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"
14#include "arene/base/stdlib_choice/integral_constant.hpp"
15#include "arene/base/stdlib_choice/is_lvalue_reference.hpp"
17// parasoft-end-suppress AUTOSAR-A16_2_2-a-2 "Arene Base aggregate headers permitted by A16-2-2 Permit #1"
18
19namespace arene {
20namespace base {
21namespace ranges {
22
23/// @brief Predicate to check if a type is a borrowed range.
24/// @tparam Rng The type to check.
25/// @return bool Equivalent to @c is_borrowed_range<Rng>::value .
26template <typename Rng>
27extern constexpr bool is_borrowed_range_v{
29};
30
31/// @brief Trait which determins if a type is a borrowed range.
32/// @tparam Rng The type to check.
33///
34/// A borrowed range is a range whose iterators remain valid even after the lifetime of the reference to the range
35/// object ends, and is thus safe to use as an input to range-based algorithms which return iterators or other
36/// references to the content in the range.
37///
38/// A type is considered a borrowed range if and only if both of the following conditions are true:
39/// 1. @c is_range<Rng> is satisfied
40/// 2. Either @c std::is_lvalue_reference<Rng> is satisfied or @c enable_borrowed_range<Rng> is specialized
41/// to be @c true
42template <typename Rng>
43class is_borrowed_range : public std::integral_constant<bool, is_borrowed_range_v<Rng>> {};
44
45} // namespace ranges
46} // namespace base
47} // namespace arene
48
49#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_RANGES_IS_BORROWED_RANGE_HPP_
Trait which determins if a type is a borrowed range.
Definition is_borrowed_range.hpp:43
A helper class to represent a compile-time constant with the specified type and value....
Definition integral_constant.hpp:23
static constexpr value_type value
Definition integral_constant.hpp:34
Definition external_vector.hpp:803
constexpr bool is_borrowed_range_v
Predicate to check if a type is a borrowed range.
constexpr bool enable_borrowed_range_v
Query if a range type has opted into being a borrowed range.
constexpr bool is_range_v
Predicate to check if a type is a range.
Definition accumulate.hpp:37
Definition accumulate.hpp:36