Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
denotes_range.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_TYPE_TRAITS_DENOTES_RANGE_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_TRAITS_DENOTES_RANGE_HPP_
7
8// IWYU pragma: private, include "arene/base/type_traits.hpp"
9// IWYU pragma: friend "(arene/base(?!/tests)|stdlib/include/stdlib_detail)/.*"
10
11#include "arene/base/constraints/constraints.hpp"
12#include "arene/base/stdlib_choice/declval.hpp"
13#include "arene/base/stdlib_choice/enable_if.hpp"
14#include "arene/base/stdlib_choice/is_copy_constructible.hpp"
15#include "arene/base/stdlib_choice/remove_cv.hpp"
16#include "arene/base/stdlib_choice/remove_reference.hpp"
17#include "arene/base/type_traits/comparison_traits.hpp"
18#include "arene/base/type_traits/iterator_category_traits.hpp"
19#include "arene/base/type_traits/remove_cvref.hpp"
20
21namespace arene {
22namespace base {
23
24/// Check if an iterator/sentinel pair form an iterable range. The value is @c true if the pair do form an iterable
25/// range, @c false otherwise.
26/// @tparam Iterator The type to check as an iterator
27/// @tparam Sentinel The type to check as a sentinel
28template <typename Iterator, typename Sentinel = Iterator>
29extern constexpr bool denotes_range_v =
33
34namespace denotes_range_detail {
35/// @brief implementation helper for @c arene::base::denotes_nothrow_iterable_range_v .
36/// This specialization handles the case that the iterator/sentinal pair do not form an iterable range
37/// @tparam Iterator The type to check as an iterator
38/// @tparam Sentinel The type to check as a sentinel
39template <typename Iterator, typename Sentinel, typename = constraints<>>
40extern constexpr bool denotes_nothrow_iterable_range_v = false;
41
42/// @brief implementation helper for @c arene::base::denotes_nothrow_iterable_range_v .
43/// This specialization handles the case that the iterator/sentinal pair do form an iterable range
44/// @tparam Iterator The type to check as an iterator
45/// @tparam Sentinel The type to check as a sentinel
46template <typename Iterator, typename Sentinel>
47extern constexpr bool denotes_nothrow_iterable_range_v<
48 Iterator,
49 Sentinel,
50 constraints<std::enable_if_t<denotes_range_v<Iterator, Sentinel>>>> =
51 noexcept(++std::declval<remove_cvref_t<Iterator>&>())&& //
52 noexcept(std::declval<remove_cvref_t<Iterator>&>()++)&& //
53 noexcept(*std::declval<remove_cvref_t<Iterator>&>())&& //
54 noexcept(std::declval<remove_cvref_t<Iterator>&>() != std::declval<remove_cvref_t<Sentinel>&>());
55
56} // namespace denotes_range_detail
57
58/// @brief Check if an iterator/sentinel pair form an iterable range that can be iterated without throwing.
59///
60/// @tparam Iterator The type to check as an iterator
61/// @tparam Sentinel The type to check as a sentinel
62/// @return true If the pair satisfies @c denotes_iterable_range and which cant be iterated without throwing: all of
63/// @c operator++ , @c operator++(int) , @c operator* , and @c operator!= are @c noexcept .
64/// @return false otherwise.
65template <typename Iterator, typename Sentinel = Iterator>
66extern constexpr bool denotes_nothrow_iterable_range_v =
68
69} // namespace base
70} // namespace arene
71
72#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_TRAITS_DENOTES_RANGE_HPP_
Definition array_exceptions_disabled.cpp:11
Copyright 2026, Toyota Motor Corporation.
Definition array_exceptions_disabled.cpp:10