tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
projected.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2024 Tobias Hienzsch
3
4#ifndef TETL_ITERATOR_PROJECTED_HPP
5#define TETL_ITERATOR_PROJECTED_HPP
6
7#include <etl/_iterator/indirect_result_t.hpp>
8#include <etl/_iterator/indirectly_readable.hpp>
9#include <etl/_iterator/indirectly_regular_unary_invocable.hpp>
10#include <etl/_iterator/iter_difference_t.hpp>
11#include <etl/_iterator/weakly_incrementable.hpp>
12#include <etl/_type_traits/remove_cvref.hpp>
13
14namespace etl {
15
16namespace detail {
17
18template <typename Iter, typename Proj>
19struct projected_impl {
20 struct type {
21 using value_type = etl::remove_cvref_t<etl::indirect_result_t<Proj&, Iter>>;
22 auto operator*() const -> etl::indirect_result_t<Proj&, Iter>; // not defined
23 };
24};
25
26template <typename Iter, typename Proj>
27 requires weakly_incrementable<Iter>
28struct projected_impl<Iter, Proj> {
29 struct type {
30 using value_type = etl::remove_cvref_t<etl::indirect_result_t<Proj&, Iter>>;
31 using difference_type = etl::iter_difference_t<Iter>; // conditionally present
32
33 auto operator*() const -> etl::indirect_result_t<Proj&, Iter>; // not defined
34 };
35};
36
37} // namespace detail
38
39/// \ingroup iterator
40template <etl::indirectly_readable Iter, etl::indirectly_regular_unary_invocable<Iter> Proj>
41using projected = etl::detail::projected_impl<Iter, Proj>::type;
42
43} // namespace etl
44
45#endif // TETL_ITERATOR_PROJECTED_HPP
Definition adjacent_find.hpp:9