std::uninitialized_move_n
From cppreference.com
| Defined in header <memory>
|
||
template< class InputIt, class Size, class NoThrowForwardIt > std::pair<InputIt, NoThrowForwardIt> |
(1) | (since C++17) (constexpr since C++26) |
| template< class ExecutionPolicy, class ForwardIt, class Size, class NoThrowForwardIt > |
(2) | (since C++17) |
1) Copies the elements from first
+ [0, count) (using move semantics if supported) to an uninitialized memory area beginning at d_first as if by
for (; count > 0; ++d_first, (void) ++first, --count)
::new (voidify(*d_first))
typename std::iterator_traits<NoThrowForwardIt>::value_type(/* value */);
return {first, d_first};
where /* value */ is std::move(*first) if *first is of an lvalue reference type, or *first otherwise.
If an exception is thrown during the initialization, some objects in first
+ [0, count) are left in a valid but unspecified state, and the objects already constructed are destroyed in an unspecified order.2) Same as (1), but executed according to policy.
This overload participates in overload resolution only if all following conditions are satisfied:
|
std::is_execution_policy_v<std::decay_t<ExecutionPolicy>> is true. |
(until C++20) |
|
std::is_execution_policy_v<std::remove_cvref_t<ExecutionPolicy>> is true. |
(since C++20) |
|
If d_first |
(since C++20) |
Contents |
[edit] Parameters
| first | - | the beginning of the range of the elements to move |
| d_first | - | the beginning of the destination range |
| count | - | the number of elements to move |
| policy | - | the execution policy to use |
| Type requirements | ||
-InputIt must meet the requirements of LegacyInputIterator.
| ||
-ForwardIt must meet the requirements of LegacyForwardIterator.
| ||
-NoThrowForwardIt must meet the requirements of LegacyForwardIterator.
| ||
-No increment, assignment, comparison, or indirection through valid instances of NoThrowForwardIt may throw exceptions.
| ||
[edit] Return value
As described above.
[edit] Complexity
Linear in count.