[uninitialized.copy] # 26 Algorithms library [[algorithms]](./#algorithms) ## 26.11 Specialized algorithms [[specialized.algorithms]](specialized.algorithms#uninitialized.copy) ### 26.11.5 uninitialized_copy [uninitialized.copy] [🔗](#lib:uninitialized_copy) `template constexpr NoThrowForwardIterator uninitialized_copy(InputIterator first, InputIterator last, NoThrowForwardIterator result); ` [1](#1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13880) *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#L13884) *Effects*: Equivalent to:for (; first != last; ++result, (void)++first)::new (*voidify*(*result))typename iterator_traits::value_type(*first); [3](#3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13893) *Returns*: result[.](#3.sentence-1) [🔗](#lib:uninitialized_copy_) `namespace ranges { template<[input_iterator](iterator.concept.input#concept:input_iterator "24.3.4.9 Concept input_­iterator [iterator.concept.input]") I, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_­for [iterator.concept.sentinel]") S1, [nothrow-forward-iterator](special.mem.concepts#concept:nothrow-forward-iterator "26.11.2 Special memory concepts [special.mem.concepts]") O, [nothrow-sentinel-for](special.mem.concepts#concept:nothrow-sentinel-for "26.11.2 Special memory concepts [special.mem.concepts]") S2> requires [constructible_from](concept.constructible#concept:constructible_from "18.4.11 Concept constructible_­from [concept.constructible]"), iter_reference_t> constexpr uninitialized_copy_result uninitialized_copy(I ifirst, S1 ilast, O ofirst, S2 olast); template<[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") IR, [nothrow-forward-range](special.mem.concepts#concept:nothrow-forward-range "26.11.2 Special memory concepts [special.mem.concepts]") OR> requires [constructible_from](concept.constructible#concept:constructible_from "18.4.11 Concept constructible_­from [concept.constructible]"), range_reference_t> constexpr uninitialized_copy_result, borrowed_iterator_t> uninitialized_copy(IR&& in_range, OR&& out_range); } ` [4](#4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13914) *Preconditions*: [ofirst, olast) does not overlap with [ifirst, ilast)[.](#4.sentence-1) [5](#5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13918) *Effects*: Equivalent to:for (; ifirst != ilast && ofirst != olast; ++ofirst, (void)++ifirst)::new (*voidify*(*ofirst)) remove_reference_t>(*ifirst);return {std::move(ifirst), ofirst}; [🔗](#lib:uninitialized_copy_n) `template constexpr NoThrowForwardIterator uninitialized_copy_n(InputIterator first, Size n, NoThrowForwardIterator result); ` [6](#6) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13936) *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#L13940) *Effects*: Equivalent to:for (; n > 0; ++result, (void)++first, --n)::new (*voidify*(*result))typename iterator_traits::value_type(*first); [8](#8) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13949) *Returns*: result[.](#8.sentence-1) [🔗](#lib:uninitialized_copy_n_) `namespace ranges { template<[input_iterator](iterator.concept.input#concept:input_iterator "24.3.4.9 Concept input_­iterator [iterator.concept.input]") I, [nothrow-forward-iterator](special.mem.concepts#concept:nothrow-forward-iterator "26.11.2 Special memory concepts [special.mem.concepts]") O, [nothrow-sentinel-for](special.mem.concepts#concept:nothrow-sentinel-for "26.11.2 Special memory concepts [special.mem.concepts]") S> requires [constructible_from](concept.constructible#concept:constructible_from "18.4.11 Concept constructible_­from [concept.constructible]"), iter_reference_t> constexpr uninitialized_copy_n_result uninitialized_copy_n(I ifirst, iter_difference_t n, O ofirst, S olast); } ` [9](#9) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13965) *Preconditions*: [ofirst, olast) does not overlap withifirst+[0, n)[.](#9.sentence-1) [10](#10) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13970) *Effects*: Equivalent to:auto t = uninitialized_copy(counted_iterator(std::move(ifirst), n), default_sentinel, ofirst, olast);return {std::move(t.in).base(), t.out};