Files
2025-10-25 03:02:53 +03:00

117 lines
5.7 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[uninitialized.move]
# 26 Algorithms library [[algorithms]](./#algorithms)
## 26.11 Specialized <memory> algorithms [[specialized.algorithms]](specialized.algorithms#uninitialized.move)
### 26.11.6 uninitialized_move [uninitialized.move]
[🔗](#lib:uninitialized_move)
`template<class InputIterator, class NoThrowForwardIterator>
constexpr NoThrowForwardIterator uninitialized_move(InputIterator first, InputIterator last,
NoThrowForwardIterator result);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13990)
*Preconditions*: result+[0, (last - first)) does not overlap with [first, last)[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13994)
*Effects*: Equivalent to:for (; first != last; (void)++result, ++first)::new (*voidify*(*result))typename iterator_traits<NoThrowForwardIterator>::value_type(*deref-move*(first));return result;
[🔗](#lib:uninitialized_move_)
`namespace ranges {
template<[input_iterator](iterator.concept.input#concept:input_iterator "24.3.4.9Concept input_­iterator[iterator.concept.input]") I, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7Concept sentinel_­for[iterator.concept.sentinel]")<I> S1,
[nothrow-forward-iterator](special.mem.concepts#concept:nothrow-forward-iterator "26.11.2Special memory concepts[special.mem.concepts]") O, [nothrow-sentinel-for](special.mem.concepts#concept:nothrow-sentinel-for "26.11.2Special memory concepts[special.mem.concepts]")<O> S2>
requires [constructible_from](concept.constructible#concept:constructible_from "18.4.11Concept constructible_­from[concept.constructible]")<iter_value_t<O>, iter_rvalue_reference_t<I>>
constexpr uninitialized_move_result<I, O>
uninitialized_move(I ifirst, S1 ilast, O ofirst, S2 olast);
template<[input_range](range.refinements#concept:input_range "25.4.6Other range refinements[range.refinements]") IR, [nothrow-forward-range](special.mem.concepts#concept:nothrow-forward-range "26.11.2Special memory concepts[special.mem.concepts]") OR>
requires [constructible_from](concept.constructible#concept:constructible_from "18.4.11Concept constructible_­from[concept.constructible]")<range_value_t<OR>, range_rvalue_reference_t<IR>>
constexpr uninitialized_move_result<borrowed_iterator_t<IR>, borrowed_iterator_t<OR>>
uninitialized_move(IR&& in_range, OR&& out_range);
}
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14021)
*Preconditions*: [ofirst, olast) does not overlap with [ifirst, ilast)[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14025)
*Effects*: Equivalent to:for (; ifirst != ilast && ofirst != olast; ++ofirst, (void)++ifirst)::new (*voidify*(*ofirst)) remove_reference_t<iter_reference_t<O>>(ranges::iter_move(ifirst));return {std::move(ifirst), ofirst};
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14035)
[*Note [1](#note-1)*:
If an exception is thrown, some objects in the range [ifirst, ilast) are
left in a valid, but unspecified state[.](#5.sentence-1)
— *end note*]
[🔗](#lib:uninitialized_move_n)
`template<class InputIterator, class Size, class NoThrowForwardIterator>
constexpr pair<InputIterator, NoThrowForwardIterator>
uninitialized_move_n(InputIterator first, Size n, NoThrowForwardIterator result);
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14050)
*Preconditions*: result+[0, n) does not overlap with first+[0, n)[.](#6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14054)
*Effects*: Equivalent to:for (; n > 0; ++result, (void)++first, --n)::new (*voidify*(*result))typename iterator_traits<NoThrowForwardIterator>::value_type(*deref-move*(first));return {first, result};
[🔗](#lib:uninitialized_move_n_)
`namespace ranges {
template<[input_iterator](iterator.concept.input#concept:input_iterator "24.3.4.9Concept input_­iterator[iterator.concept.input]") I, [nothrow-forward-iterator](special.mem.concepts#concept:nothrow-forward-iterator "26.11.2Special memory concepts[special.mem.concepts]") O, [nothrow-sentinel-for](special.mem.concepts#concept:nothrow-sentinel-for "26.11.2Special memory concepts[special.mem.concepts]")<O> S>
requires [constructible_from](concept.constructible#concept:constructible_from "18.4.11Concept constructible_­from[concept.constructible]")<iter_value_t<O>, iter_rvalue_reference_t<I>>
constexpr uninitialized_move_n_result<I, O>
uninitialized_move_n(I ifirst, iter_difference_t<I> n, O ofirst, S olast);
}
`
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14076)
*Preconditions*: [ofirst, olast) does not overlap with ifirst+[0, n)[.](#8.sentence-1)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14080)
*Effects*: Equivalent to:auto t = uninitialized_move(counted_iterator(std::move(ifirst), n),
default_sentinel, ofirst, olast);return {std::move(t.in).base(), t.out};
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14089)
[*Note [2](#note-2)*:
If an exception is thrown, some objects in the rangeifirst+[0, n) are left in a valid but unspecified state[.](#10.sentence-1)
— *end note*]