tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
ranges_iter_move.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_ITERATOR_RANGES_ITER_MOVE_HPP
4#define TETL_ITERATOR_RANGES_ITER_MOVE_HPP
5
11#include <etl/_utility/move.hpp>
12
13namespace etl::ranges {
14
15namespace iter_move_cpo {
16
17auto iter_move() -> void = delete;
18
19template <typename T>
21 and requires(T&& t) { iter_move(etl::forward<T>(t)); };
22
23template <typename T>
24concept can_move = not adl_iter_move<T> and requires(T&& t) {
25 *t;
26 requires is_lvalue_reference_v<decltype(*t)>;
27};
28
29template <typename T>
30concept can_deref = not adl_iter_move<T> and !can_move<T> and requires(T&& t) {
31 *t;
32 requires(!is_lvalue_reference_v<decltype(*t)>);
33};
34
35struct fn {
36 template <adl_iter_move Iter>
37 [[nodiscard]] constexpr auto operator()(Iter&& i) const noexcept(noexcept(iter_move(etl::forward<Iter>(i))))
38 -> decltype(auto)
39 {
41 }
42
43 template <can_move Iter>
44 [[nodiscard]] constexpr auto operator()(Iter&& i) const noexcept(noexcept(etl::move(*etl::forward<Iter>(i))))
45 -> decltype(etl::move(*etl::forward<Iter>(i)))
46 {
47 return etl::move(*etl::forward<Iter>(i));
48 }
49
50 template <can_deref Iter>
51 [[nodiscard]] constexpr auto operator()(Iter&& i) const noexcept(noexcept(*etl::forward<Iter>(i)))
52 -> decltype(*etl::forward<Iter>(i))
53 {
54 return *etl::forward<Iter>(i);
55 }
56};
57
58} // namespace iter_move_cpo
59
60inline namespace cpo {
62inline constexpr auto iter_move = iter_move_cpo::fn{};
63} // namespace cpo
64
65} // namespace etl::ranges
66
67#endif // TETL_ITERATOR_RANGES_ITER_MOVE_HPP
constexpr auto move(InputIt first, InputIt last, OutputIt destination) -> OutputIt
Moves the elements in the range [first, last), to another range beginning at destination,...
Definition move.hpp:26
constexpr auto iter_move
Definition ranges_iter_move.hpp:62
Definition ranges_iter_move.hpp:60
Definition ranges_in_fun_result.hpp:11
constexpr bool is_lvalue_reference_v
Definition is_lvalue_reference.hpp:20
constexpr bool is_enum_v
Definition is_enum.hpp:16
constexpr bool is_class_v
Definition is_class.hpp:16
constexpr auto forward(remove_reference_t< T > &param) noexcept -> T &&
Forwards lvalues as either lvalues or as rvalues, depending on T. When t is a forwarding reference (a...
Definition forward.hpp:18