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
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"
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 =
32 std::is_copy_constructible<remove_cvref_t<Sentinel>>::value;
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,
51 noexcept(++std::declval<remove_cvref_t<Iterator>&>())&& //
52 noexcept(std::declval<remove_cvref_t<Iterator>&>()++)&& //
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 =
67 denotes_range_detail::denotes_nothrow_iterable_range_v<Iterator, Sentinel>;
68
69} // namespace base
70} // namespace arene
71
72#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_TRAITS_DENOTES_RANGE_HPP_
Definition accumulate.hpp:37
constexpr bool denotes_nothrow_iterable_range_v
Check if an iterator/sentinel pair form an iterable range that can be iterated without throwing.
constexpr bool is_iterator_v
Definition iterator_category_traits.hpp:375
constexpr bool is_inequality_comparable_v
constexpr bool denotes_range_v
typename constraints_impl::constraints< EnableIfs... >::type constraints
Helper used to express template constraints in a consistent way using std::enable_if_t.
Definition constraints.hpp:51
remove_cv_t< remove_reference_t< T > > remove_cvref_t
Backport of std::remove_cvref_t.
Definition remove_cvref.hpp:35
Definition accumulate.hpp:36
auto declval() noexcept -> T &&
A dummy function that is declared but not defined, with a user-specified return type,...