tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
ranges_destroy.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_MEMORY_RANGES_DESTROY_HPP
5#define TETL_MEMORY_RANGES_DESTROY_HPP
6
7#include <etl/_concepts/destructible.hpp>
8#include <etl/_iterator/iter_value_t.hpp>
9#include <etl/_memory/addressof.hpp>
10#include <etl/_memory/ranges_destroy_at.hpp>
11#include <etl/_ranges/begin.hpp>
12#include <etl/_ranges/end.hpp>
13#include <etl/_ranges/range_value_t.hpp>
14#include <etl/_type_traits/is_function.hpp>
15
16namespace etl::ranges {
17
18inline constexpr struct destroy_fn {
19 template <typename /*no-throw-input-iterator*/ I, typename /*no-throw-sentinel-for<I>*/ S>
20 requires etl::destructible<etl::iter_value_t<I>>
21 constexpr auto operator()(I first, S last) const noexcept -> I
22 {
23 for (; first != last; ++first) {
24 etl::ranges::destroy_at(etl::addressof(*first));
25 }
26 return first;
27 }
28
29 template <typename /*no-throw-input-range*/ R>
30 requires etl::destructible<etl::ranges::range_value_t<R>>
31 constexpr auto operator()(R&& r) const noexcept -> auto /*etl::ranges::borrowed_iterator_t<R>*/
32 {
34 }
35} destroy;
36
37} // namespace etl::ranges
38
39#endif // TETL_MEMORY_RANGES_DESTROY_HPP
constexpr auto end
Definition end.hpp:57
constexpr auto begin
Definition begin.hpp:62
Definition ranges_in_fun_result.hpp:12
Definition adjacent_find.hpp:9
Definition ranges_destroy.hpp:18
constexpr auto operator()(R &&r) const noexcept -> auto
Definition ranges_destroy.hpp:31
constexpr auto operator()(I first, S last) const noexcept -> I
Definition ranges_destroy.hpp:21