tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
end.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_RANGES_END_HPP
4#define TETL_RANGES_END_HPP
5
11
12namespace etl::ranges {
13
14namespace end_cpo {
15
16auto end(auto&) -> void = delete;
17auto end(auto const&) -> void = delete;
18
19template <typename T>
20concept has_member_end = ranges::detail::can_borrow<T> and requires(T&& t) {
21 { decay_copy(t.end()) } -> etl::sentinel_for<etl::ranges::iterator_t<T>>;
22};
23
24template <typename T>
25concept has_adl_end = not has_member_end<T> and ranges::detail::can_borrow<T> and requires(T&& t) {
26 { decay_copy(end(t)) } -> etl::sentinel_for<etl::ranges::iterator_t<T>>;
27};
28
29struct fn {
30 template <typename T, etl::size_t Size>
31 requires(sizeof(T) >= 0) // NOLINT(bugprone-sizeof-expression)
32 [[nodiscard]] constexpr auto operator()(T (&t)[Size]) const noexcept
33 {
34 return t + Size;
35 }
36
37 template <has_member_end T>
38 [[nodiscard]] constexpr auto operator()(T&& t) const noexcept(noexcept(decay_copy(t.end())))
39 {
40 return decay_copy(t.end());
41 }
42
43 template <has_adl_end T>
44 [[nodiscard]] constexpr auto operator()(T&& t) const noexcept(noexcept(decay_copy(end(t))))
45 {
46 return decay_copy(end(t));
47 }
48
49 auto operator()(auto&&) const -> void = delete;
50};
51
52} // namespace end_cpo
53
54inline namespace cpo {
56inline constexpr auto end = end_cpo::fn{};
57} // namespace cpo
58
59} // namespace etl::ranges
60
61#endif // TETL_RANGES_END_HPP
constexpr auto decay_copy(T &&t) noexcept(is_nothrow_convertible_v< T, decay_t< T > >) -> decay_t< T >
Definition decay_copy.hpp:14
constexpr auto end
Definition end.hpp:56
Definition ranges_in_fun_result.hpp:11