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
3#ifndef TETL_MEMORY_UNINITIALIZED_MOVE_HPP
4#define TETL_MEMORY_UNINITIALIZED_MOVE_HPP
5
10
11namespace etl {
12
13template <typename InputIt, typename NoThrowForwardIt>
14constexpr auto uninitialized_move(InputIt first, InputIt last, NoThrowForwardIt dest) -> NoThrowForwardIt
15{
16#if defined(__cpp_exceptions)
17 auto current = dest;
18 try {
19 for (; first != last; ++first, (void)++current) {
20 etl::construct_at(etl::addressof(*current), etl::move(*first));
21 }
22 return current;
23 } catch (...) {
24 etl::destroy(dest, current);
25 throw;
26 }
27#else
28 auto current = dest;
29 for (; first != last; ++first, (void)++current) {
30 etl::construct_at(etl::addressof(*current), etl::move(*first));
31 }
32 return current;
33#endif
34}
35
36} // namespace etl
37
38#endif // TETL_MEMORY_UNINITIALIZED_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
Definition adjacent_find.hpp:8
constexpr auto addressof(T &arg) noexcept -> T *
Obtains the actual address of the object or function arg, even in presence of overloaded operator&.
Definition addressof.hpp:15
constexpr auto construct_at(T *p, Args &&... args) -> T *
Creates a T object initialized with arguments args... at given address p.
Definition construct_at.hpp:38
constexpr auto destroy(ForwardIt first, ForwardIt last) -> void
Destroys the objects in the range [first, last).
Definition destroy.hpp:13
constexpr auto uninitialized_move(InputIt first, InputIt last, NoThrowForwardIt dest) -> NoThrowForwardIt
Definition uninitialized_move.hpp:14