Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
is_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_RANGE_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_RANGES_IS_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/declval.hpp"
15#include "arene/base/stdlib_choice/integral_constant.hpp"
16// parasoft-end-suppress AUTOSAR-A16_2_2-a-2 "Arene Base aggregate headers permitted by A16-2-2 Permit #1"
17
18namespace arene {
19namespace base {
20namespace ranges {
21
22namespace is_range_detail {
23/// @brief Helper trait for deducing if @c ranges::begin is well-formed for a given type @c Rng .
24/// @tparam Rng The type to check.
25/// @note This is needed rather than just using @c iterator_t because @c iterator_t automatically corrects the input
26/// range type to an lvalue reference, which is not what we want for this trait.
27template <typename Rng>
28using use_begin = decltype(::arene::base::ranges::begin(std::declval<Rng>()));
29
30/// @brief Helper trait for deducing if @c ranges::end is well-formed for a given type @c Rng .
31/// @tparam Rng The type to check.
32/// @note This is needed rather than just using @c sentinel_t because @c sentinel_t automatically corrects the input
33/// range type to an lvalue reference, which is not what we want for this trait.
34template <typename Rng>
35using use_end = decltype(::arene::base::ranges::end(std::declval<Rng>()));
36
37} // namespace is_range_detail
38
39/// @brief Predicate to check if a type is a range.
40/// @tparam Rng The type to check.
41/// @return bool @c true if @c Rng is a range, @c false otherwise. A type @c Rng is considered a range if and only if
42/// all of the following are true when considering an instance @c rng of <c>Rng</c>, with the ref-qualification of
43/// @c Rng preserved:
44/// 1. @c ranges::begin(rng) is a well-formed expression.
45/// 2. @c ranges::end(rng) is a well-formed expression.
46template <typename Rng>
47extern constexpr bool
49
50/// @brief Trait which determins if a type is a range.
51/// @tparam Rng The type to check.
52/// The member @c value is equivalent to @c is_range_v<Rng> .
53template <typename Rng>
54class is_range : public std::integral_constant<bool, is_range_v<Rng>> {};
55
56} // namespace ranges
57} // namespace base
58} // namespace arene
59
60#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_RANGES_IS_RANGE_HPP_
Trait which determins if a type is a range.
Definition is_range.hpp:54
A helper class to represent a compile-time constant with the specified type and value....
Definition integral_constant.hpp:23
Definition external_vector.hpp:803
constexpr bool is_range_v
Predicate to check if a type is a range.
Definition accumulate.hpp:37
constexpr bool substitution_succeeds
Determines if a template can be instantiated successfully, similar to C++20's requires clause.
Definition accumulate.hpp:36
auto declval() noexcept -> T &&
A dummy function that is declared but not defined, with a user-specified return type,...