tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
uninitialized_move.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_UNINITIALIZED_MOVE_HPP
5#define TETL_MEMORY_UNINITIALIZED_MOVE_HPP
6
7#include <etl/_memory/addressof.hpp>
8#include <etl/_memory/construct_at.hpp>
9#include <etl/_memory/destroy.hpp>
10#include <etl/_utility/move.hpp>
11
12namespace etl {
13
14template <typename InputIt, typename NoThrowForwardIt>
15constexpr auto uninitialized_move(InputIt first, InputIt last, NoThrowForwardIt dest) -> NoThrowForwardIt
16{
17#if defined(__cpp_exceptions)
18 auto current = dest;
19 try {
20 for (; first != last; ++first, (void)++current) {
21 etl::construct_at(etl::addressof(*current), etl::move(*first));
22 }
23 return current;
24 } catch (...) {
25 etl::destroy(dest, current);
26 throw;
27 }
28#else
29 auto current = dest;
30 for (; first != last; ++first, (void)++current) {
31 etl::construct_at(etl::addressof(*current), etl::move(*first));
32 }
33 return current;
34#endif
35}
36
37} // namespace etl
38
39#endif // TETL_MEMORY_UNINITIALIZED_MOVE_HPP
Definition adjacent_find.hpp:9
constexpr auto uninitialized_move(InputIt first, InputIt last, NoThrowForwardIt dest) -> NoThrowForwardIt
Definition uninitialized_move.hpp:15