[specialized.algorithms]

# 26 Algorithms library [[algorithms]](./#algorithms)

## 26.11 Specialized <memory> algorithms [specialized.algorithms]

### [26.11.1](#general) General [[specialized.algorithms.general]](specialized.algorithms.general)

[1](#general-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13503)

The contents specified in [specialized.algorithms]
are declared in the header [<memory>](memory.syn#header:%3cmemory%3e "20.2.2 Header <memory> synopsis [memory.syn]")[.](#general-1.sentence-1)

[2](#general-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13507)

Unless otherwise specified,
if an exception is thrown in the following algorithms,
objects constructed by a placement [*new-expression*](expr.new#nt:new-expression "7.6.2.8 New [expr.new]") ([[expr.new]](expr.new "7.6.2.8 New"))
are destroyed in an unspecified order
before allowing the exception to propagate[.](#general-2.sentence-1)

[3](#general-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13514)

[*Note [1](#general-note-1)*:

When new objects are created by
the algorithms specified in [specialized.algorithms],
the lifetime ends for any existing objects
(including potentially-overlapping subobjects [[intro.object]](intro.object "6.8.2 Object model"))
in storage that is reused [[basic.life]](basic.life "6.8.4 Lifetime")[.](#general-3.sentence-1)

â *end note*]

[4](#general-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13523)

Some algorithms specified in [specialized.algorithms]
make use of the following exposition-only function templates:template<class T>constexpr void* *voidify*(T& obj) noexcept {return addressof(obj); }template<class I>decltype(auto) *deref-move*(I& it) {if constexpr (is_lvalue_reference_v<decltype(*it)>)return std::move(*it); elsereturn *it; }

### [26.11.2](#special.mem.concepts) Special memory concepts [[special.mem.concepts]](special.mem.concepts)

[1](#special.mem.concepts-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13543)

Some algorithms in this subclause are constrained with the following
exposition-only concepts:

[ð](#concept:nothrow-input-iterator)

`template<class I>
concept [nothrow-input-iterator](#concept:nothrow-input-iterator "26.11.2 Special memory concepts [special.mem.concepts]") = // exposition only
  [input_iterator](iterator.concept.input#concept:input_iterator "24.3.4.9 Concept input_­iterator [iterator.concept.input]")<I> &&
  is_lvalue_reference_v<iter_reference_t<I>> &&
  [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<remove_cvref_t<iter_reference_t<I>>, iter_value_t<I>>;
`

[2](#special.mem.concepts-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13555)

A type I models [*nothrow-input-iterator*](#concept:nothrow-input-iterator "26.11.2 Special memory concepts [special.mem.concepts]") only if
no exceptions are thrown from increment,
copy construction, move construction,
copy assignment, move assignment,
or indirection through valid iterators[.](#special.mem.concepts-2.sentence-1)

[3](#special.mem.concepts-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13562)

[*Note [1](#special.mem.concepts-note-1)*:

This concept allows some [input_iterator](iterator.concept.input#concept:input_iterator "24.3.4.9 Concept input_­iterator [iterator.concept.input]") ([[iterator.concept.input]](iterator.concept.input "24.3.4.9 Concept input_­iterator"))
operations to throw exceptions[.](#special.mem.concepts-3.sentence-1)

â *end note*]

[ð](#concept:nothrow-sentinel-for)

`template<class S, class I>
concept [nothrow-sentinel-for](#concept:nothrow-sentinel-for "26.11.2 Special memory concepts [special.mem.concepts]") = [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_­for [iterator.concept.sentinel]")<S, I>; // exposition only
`

[4](#special.mem.concepts-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13575)

Types S and I model [*nothrow-sentinel-for*](#concept:nothrow-sentinel-for "26.11.2 Special memory concepts [special.mem.concepts]") only if no exceptions are thrown from copy construction, move construction,
copy assignment, move assignment, or comparisons between
valid values of type I and S[.](#special.mem.concepts-4.sentence-1)

[5](#special.mem.concepts-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13581)

[*Note [2](#special.mem.concepts-note-2)*:

This concept allows some [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_­for [iterator.concept.sentinel]") ([[iterator.concept.sentinel]](iterator.concept.sentinel "24.3.4.7 Concept sentinel_­for"))
operations to throw exceptions[.](#special.mem.concepts-5.sentence-1)

â *end note*]

[ð](#concept:nothrow-sized-sentinel-for)

`template<class S, class I>
concept [nothrow-sized-sentinel-for](#concept:nothrow-sized-sentinel-for "26.11.2 Special memory concepts [special.mem.concepts]") = // exposition only
  [nothrow-sentinel-for](#concept:nothrow-sentinel-for "26.11.2 Special memory concepts [special.mem.concepts]")<S, I> &&
  [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_­sentinel_­for [iterator.concept.sizedsentinel]")<S, I>;
`

[6](#special.mem.concepts-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13596)

Types S and I model [*nothrow-sized-sentinel-for*](#concept:nothrow-sized-sentinel-for "26.11.2 Special memory concepts [special.mem.concepts]") only if no exceptions are thrown from the - operator
for valid values of type I and S[.](#special.mem.concepts-6.sentence-1)

[7](#special.mem.concepts-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13601)

[*Note [3](#special.mem.concepts-note-3)*:

This concept allows some [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_­sentinel_­for [iterator.concept.sizedsentinel]") ([[iterator.concept.sizedsentinel]](iterator.concept.sizedsentinel "24.3.4.8 Concept sized_­sentinel_­for"))
operations to throw exceptions[.](#special.mem.concepts-7.sentence-1)

â *end note*]

[ð](#concept:nothrow-input-range)

`template<class R>
concept [nothrow-input-range](#concept:nothrow-input-range "26.11.2 Special memory concepts [special.mem.concepts]") = // exposition only
  [range](range.range#concept:range "25.4.2 Ranges [range.range]")<R> &&
  [nothrow-input-iterator](#concept:nothrow-input-iterator "26.11.2 Special memory concepts [special.mem.concepts]")<iterator_t<R>> &&
  [nothrow-sentinel-for](#concept:nothrow-sentinel-for "26.11.2 Special memory concepts [special.mem.concepts]")<sentinel_t<R>, iterator_t<R>>;
`

[8](#special.mem.concepts-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13617)

A type R models [*nothrow-input-range*](#concept:nothrow-input-range "26.11.2 Special memory concepts [special.mem.concepts]") only if
no exceptions are thrown from calls to ranges​::​begin andranges​::​end on an object of type R[.](#special.mem.concepts-8.sentence-1)

[ð](#concept:nothrow-forward-iterator)

`template<class I>
concept [nothrow-forward-iterator](#concept:nothrow-forward-iterator "26.11.2 Special memory concepts [special.mem.concepts]") = // exposition only
  [nothrow-input-iterator](#concept:nothrow-input-iterator "26.11.2 Special memory concepts [special.mem.concepts]")<I> &&
  [forward_iterator](iterator.concept.forward#concept:forward_iterator "24.3.4.11 Concept forward_­iterator [iterator.concept.forward]")<I> &&
  [nothrow-sentinel-for](#concept:nothrow-sentinel-for "26.11.2 Special memory concepts [special.mem.concepts]")<I, I>;
`

[9](#special.mem.concepts-9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13632)

[*Note [4](#special.mem.concepts-note-4)*:

This concept allows some [forward_iterator](iterator.concept.forward#concept:forward_iterator "24.3.4.11 Concept forward_­iterator [iterator.concept.forward]") ([[iterator.concept.forward]](iterator.concept.forward "24.3.4.11 Concept forward_­iterator"))
operations to throw exceptions[.](#special.mem.concepts-9.sentence-1)

â *end note*]

[ð](#concept:nothrow-forward-range)

`template<class R>
concept [nothrow-forward-range](#concept:nothrow-forward-range "26.11.2 Special memory concepts [special.mem.concepts]") = // exposition only
  [nothrow-input-range](#concept:nothrow-input-range "26.11.2 Special memory concepts [special.mem.concepts]")<R> &&
  [nothrow-forward-iterator](#concept:nothrow-forward-iterator "26.11.2 Special memory concepts [special.mem.concepts]")<iterator_t<R>>;
`

[ð](#concept:nothrow-bidirectional-iterator)

`template<class I>
concept [nothrow-bidirectional-iterator](#concept:nothrow-bidirectional-iterator "26.11.2 Special memory concepts [special.mem.concepts]") = // exposition only
  [nothrow-forward-iterator](#concept:nothrow-forward-iterator "26.11.2 Special memory concepts [special.mem.concepts]")<I> &&
  [bidirectional_iterator](iterator.concept.bidir#concept:bidirectional_iterator "24.3.4.12 Concept bidirectional_­iterator [iterator.concept.bidir]")<I>;
`

[10](#special.mem.concepts-10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13654)

A type I models [*nothrow-bidirectional-iterator*](#concept:nothrow-bidirectional-iterator "26.11.2 Special memory concepts [special.mem.concepts]") only if no exceptions are thrown from decrementing valid iterators[.](#special.mem.concepts-10.sentence-1)

[*Note [5](#special.mem.concepts-note-5)*:

This concept allows some [bidirectional_iterator](iterator.concept.bidir#concept:bidirectional_iterator "24.3.4.12 Concept bidirectional_­iterator [iterator.concept.bidir]") ([[iterator.concept.bidir]](iterator.concept.bidir "24.3.4.12 Concept bidirectional_­iterator"))
operations to throw exceptions[.](#special.mem.concepts-10.sentence-2)

â *end note*]

[ð](#concept:nothrow-bidirectional-range)

`template<class R>
concept [nothrow-bidirectional-range](#concept:nothrow-bidirectional-range "26.11.2 Special memory concepts [special.mem.concepts]") = // exposition only
  [nothrow-forward-range](#concept:nothrow-forward-range "26.11.2 Special memory concepts [special.mem.concepts]")<R> &&
  [nothrow-bidirectional-iterator](#concept:nothrow-bidirectional-iterator "26.11.2 Special memory concepts [special.mem.concepts]")<iterator_t<R>>;
`

[ð](#concept:nothrow-random-access-iterator)

`template<class I>
concept [nothrow-random-access-iterator](#concept:nothrow-random-access-iterator "26.11.2 Special memory concepts [special.mem.concepts]") = // exposition only
  [nothrow-bidirectional-iterator](#concept:nothrow-bidirectional-iterator "26.11.2 Special memory concepts [special.mem.concepts]")<I> &&
  [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]")<I> &&
  [nothrow-sized-sentinel-for](#concept:nothrow-sized-sentinel-for "26.11.2 Special memory concepts [special.mem.concepts]")<I, I>;
`

[11](#special.mem.concepts-11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13679)

A type I models [*nothrow-random-access-iterator*](#concept:nothrow-random-access-iterator "26.11.2 Special memory concepts [special.mem.concepts]") only if no exceptions are thrown from comparisons of valid iterators,
or the -, +, -=, +=, [] operators
on valid values of type I and iter_difference_t<I>[.](#special.mem.concepts-11.sentence-1)

[*Note [6](#special.mem.concepts-note-6)*:

This concept allows some [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]") ([[iterator.concept.random.access]](iterator.concept.random.access "24.3.4.13 Concept random_­access_­iterator"))
operations to throw exceptions[.](#special.mem.concepts-11.sentence-2)

â *end note*]

[ð](#special.mem.concepts-itemdecl:10)

`template<class R>
concept [nothrow-random-access-range](#concept:nothrow-random-access-range "26.11.2 Special memory concepts [special.mem.concepts]") = // exposition only
  [nothrow-bidirectional-range](#concept:nothrow-bidirectional-range "26.11.2 Special memory concepts [special.mem.concepts]")<R> &&
  [nothrow-random-access-iterator](#concept:nothrow-random-access-iterator "26.11.2 Special memory concepts [special.mem.concepts]")<iterator_t<R>>;

template<class R>
concept [nothrow-sized-random-access-range](#concept:nothrow-sized-random-access-range "26.11.2 Special memory concepts [special.mem.concepts]") = // exposition only
  [nothrow-random-access-range](#concept:nothrow-random-access-range "26.11.2 Special memory concepts [special.mem.concepts]")<R> && [sized_range](range.sized#concept:sized_range "25.4.4 Sized ranges [range.sized]")<R>;
`

[12](#special.mem.concepts-12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13702)

A type R models [*nothrow-sized-random-access-range*](#concept:nothrow-sized-random-access-range "26.11.2 Special memory concepts [special.mem.concepts]") only if no exceptions are thrown from the call to ranges​::​size on an object of type R[.](#special.mem.concepts-12.sentence-1)

### [26.11.3](#uninitialized.construct.default) uninitialized_default_construct [[uninitialized.construct.default]](uninitialized.construct.default)

[ð](#lib:uninitialized_default_construct)

`template<class NoThrowForwardIterator>
  constexpr void uninitialized_default_construct(NoThrowForwardIterator first,
                                                 NoThrowForwardIterator last);
`

[1](#uninitialized.construct.default-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13718)

*Effects*: Equivalent to:for (; first != last; ++first)::new (*voidify*(*first))typename iterator_traits<NoThrowForwardIterator>::value_type;

[ð](#lib:uninitialized_default_construct_)

`namespace ranges {
  template<[nothrow-forward-iterator](#concept:nothrow-forward-iterator "26.11.2 Special memory concepts [special.mem.concepts]") I, [nothrow-sentinel-for](#concept:nothrow-sentinel-for "26.11.2 Special memory concepts [special.mem.concepts]")<I> S>
    requires [default_initializable](concept.default.init#concept:default_initializable "18.4.12 Concept default_­initializable [concept.default.init]")<iter_value_t<I>>
    constexpr I uninitialized_default_construct(I first, S last);
  template<[nothrow-forward-range](#concept:nothrow-forward-range "26.11.2 Special memory concepts [special.mem.concepts]") R>
    requires [default_initializable](concept.default.init#concept:default_initializable "18.4.12 Concept default_­initializable [concept.default.init]")<range_value_t<R>>
    constexpr borrowed_iterator_t<R> uninitialized_default_construct(R&& r);
}
`

[2](#uninitialized.construct.default-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13741)

*Effects*: Equivalent to:for (; first != last; ++first)::new (*voidify*(*first)) remove_reference_t<iter_reference_t<I>>;return first;

[ð](#lib:uninitialized_default_construct_n)

`template<class NoThrowForwardIterator, class Size>
  constexpr NoThrowForwardIterator
    uninitialized_default_construct_n(NoThrowForwardIterator first, Size n);
`

[3](#uninitialized.construct.default-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13759)

*Effects*: Equivalent to:for (; n > 0; (void)++first, --n)::new (*voidify*(*first))typename iterator_traits<NoThrowForwardIterator>::value_type;return first;

[ð](#lib:uninitialized_default_construct_n_)

`namespace ranges {
  template<[nothrow-forward-iterator](#concept:nothrow-forward-iterator "26.11.2 Special memory concepts [special.mem.concepts]") I>
    requires [default_initializable](concept.default.init#concept:default_initializable "18.4.12 Concept default_­initializable [concept.default.init]")<iter_value_t<I>>
    constexpr I uninitialized_default_construct_n(I first, iter_difference_t<I> n);
}
`

[4](#uninitialized.construct.default-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13780)

*Effects*: Equivalent to:return uninitialized_default_construct(counted_iterator(first, n),
 default_sentinel).base();

### [26.11.4](#uninitialized.construct.value) uninitialized_value_construct [[uninitialized.construct.value]](uninitialized.construct.value)

[ð](#lib:uninitialized_value_construct)

`template<class NoThrowForwardIterator>
  constexpr void uninitialized_value_construct(NoThrowForwardIterator first,
                                               NoThrowForwardIterator last);
`

[1](#uninitialized.construct.value-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13799)

*Effects*: Equivalent to:for (; first != last; ++first)::new (*voidify*(*first))typename iterator_traits<NoThrowForwardIterator>::value_type();

[ð](#lib:uninitialized_value_construct_)

`namespace ranges {
  template<[nothrow-forward-iterator](#concept:nothrow-forward-iterator "26.11.2 Special memory concepts [special.mem.concepts]") I, [nothrow-sentinel-for](#concept:nothrow-sentinel-for "26.11.2 Special memory concepts [special.mem.concepts]")<I> S>
    requires [default_initializable](concept.default.init#concept:default_initializable "18.4.12 Concept default_­initializable [concept.default.init]")<iter_value_t<I>>
    constexpr I uninitialized_value_construct(I first, S last);
  template<[nothrow-forward-range](#concept:nothrow-forward-range "26.11.2 Special memory concepts [special.mem.concepts]") R>
    requires [default_initializable](concept.default.init#concept:default_initializable "18.4.12 Concept default_­initializable [concept.default.init]")<range_value_t<R>>
    constexpr borrowed_iterator_t<R> uninitialized_value_construct(R&& r);
}
`

[2](#uninitialized.construct.value-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13822)

*Effects*: Equivalent to:for (; first != last; ++first)::new (*voidify*(*first)) remove_reference_t<iter_reference_t<I>>();return first;

[ð](#lib:uninitialized_value_construct_n)

`template<class NoThrowForwardIterator, class Size>
  constexpr NoThrowForwardIterator
    uninitialized_value_construct_n(NoThrowForwardIterator first, Size n);
`

[3](#uninitialized.construct.value-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13840)

*Effects*: Equivalent to:for (; n > 0; (void)++first, --n)::new (*voidify*(*first))typename iterator_traits<NoThrowForwardIterator>::value_type();return first;

[ð](#lib:uninitialized_value_construct_n_)

`namespace ranges {
  template<[nothrow-forward-iterator](#concept:nothrow-forward-iterator "26.11.2 Special memory concepts [special.mem.concepts]") I>
    requires [default_initializable](concept.default.init#concept:default_initializable "18.4.12 Concept default_­initializable [concept.default.init]")<iter_value_t<I>>
    constexpr I uninitialized_value_construct_n(I first, iter_difference_t<I> n);
}
`

[4](#uninitialized.construct.value-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13861)

*Effects*: Equivalent to:return uninitialized_value_construct(counted_iterator(first, n),
 default_sentinel).base();

### [26.11.5](#uninitialized.copy) uninitialized_copy [[uninitialized.copy]](uninitialized.copy)

[ð](#lib:uninitialized_copy)

`template<class InputIterator, class NoThrowForwardIterator>
  constexpr NoThrowForwardIterator uninitialized_copy(InputIterator first, InputIterator last,
                                                      NoThrowForwardIterator result);
`

[1](#uninitialized.copy-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13880)

*Preconditions*: result+[0, (last - first)) does not overlap with [first, last)[.](#uninitialized.copy-1.sentence-1)

[2](#uninitialized.copy-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<NoThrowForwardIterator>::value_type(*first);

[3](#uninitialized.copy-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13893)

*Returns*: result[.](#uninitialized.copy-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]")<I> S1,
           [nothrow-forward-iterator](#concept:nothrow-forward-iterator "26.11.2 Special memory concepts [special.mem.concepts]") O, [nothrow-sentinel-for](#concept:nothrow-sentinel-for "26.11.2 Special memory concepts [special.mem.concepts]")<O> S2>
    requires [constructible_from](concept.constructible#concept:constructible_from "18.4.11 Concept constructible_­from [concept.constructible]")<iter_value_t<O>, iter_reference_t<I>>
    constexpr uninitialized_copy_result<I, O>
      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](#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_value_t<OR>, range_reference_t<IR>>
    constexpr uninitialized_copy_result<borrowed_iterator_t<IR>, borrowed_iterator_t<OR>>
      uninitialized_copy(IR&& in_range, OR&& out_range);
}
`

[4](#uninitialized.copy-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13914)

*Preconditions*: [ofirst, olast) does not overlap with [ifirst, ilast)[.](#uninitialized.copy-4.sentence-1)

[5](#uninitialized.copy-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<iter_reference_t<O>>(*ifirst);return {std::move(ifirst), ofirst};

[ð](#lib:uninitialized_copy_n)

`template<class InputIterator, class Size, class NoThrowForwardIterator>
  constexpr NoThrowForwardIterator uninitialized_copy_n(InputIterator first, Size n,
                                                        NoThrowForwardIterator result);
`

[6](#uninitialized.copy-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13936)

*Preconditions*: result+[0, n) does not overlap with first+[0, n)[.](#uninitialized.copy-6.sentence-1)

[7](#uninitialized.copy-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<NoThrowForwardIterator>::value_type(*first);

[8](#uninitialized.copy-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13949)

*Returns*: result[.](#uninitialized.copy-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](#concept:nothrow-forward-iterator "26.11.2 Special memory concepts [special.mem.concepts]") O, [nothrow-sentinel-for](#concept:nothrow-sentinel-for "26.11.2 Special memory concepts [special.mem.concepts]")<O> S>
    requires [constructible_from](concept.constructible#concept:constructible_from "18.4.11 Concept constructible_­from [concept.constructible]")<iter_value_t<O>, iter_reference_t<I>>
    constexpr uninitialized_copy_n_result<I, O>
      uninitialized_copy_n(I ifirst, iter_difference_t<I> n, O ofirst, S olast);
}
`

[9](#uninitialized.copy-9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13965)

*Preconditions*: [ofirst, olast) does not overlap withifirst+[0, n)[.](#uninitialized.copy-9.sentence-1)

[10](#uninitialized.copy-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};

### [26.11.6](#uninitialized.move) uninitialized_move [[uninitialized.move]](uninitialized.move)

[ð](#lib:uninitialized_move)

`template<class InputIterator, class NoThrowForwardIterator>
  constexpr NoThrowForwardIterator uninitialized_move(InputIterator first, InputIterator last,
                                                      NoThrowForwardIterator result);
`

[1](#uninitialized.move-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13990)

*Preconditions*: result+[0, (last - first)) does not overlap with [first, last)[.](#uninitialized.move-1.sentence-1)

[2](#uninitialized.move-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.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]")<I> S1,
           [nothrow-forward-iterator](#concept:nothrow-forward-iterator "26.11.2 Special memory concepts [special.mem.concepts]") O, [nothrow-sentinel-for](#concept:nothrow-sentinel-for "26.11.2 Special memory concepts [special.mem.concepts]")<O> S2>
    requires [constructible_from](concept.constructible#concept:constructible_from "18.4.11 Concept 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.6 Other range refinements [range.refinements]") IR, [nothrow-forward-range](#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_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](#uninitialized.move-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14021)

*Preconditions*: [ofirst, olast) does not overlap with [ifirst, ilast)[.](#uninitialized.move-3.sentence-1)

[4](#uninitialized.move-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](#uninitialized.move-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14035)

[*Note [1](#uninitialized.move-note-1)*:

If an exception is thrown, some objects in the range [ifirst, ilast) are
left in a valid, but unspecified state[.](#uninitialized.move-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](#uninitialized.move-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14050)

*Preconditions*: result+[0, n) does not overlap with first+[0, n)[.](#uninitialized.move-6.sentence-1)

[7](#uninitialized.move-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.9 Concept input_­iterator [iterator.concept.input]") I, [nothrow-forward-iterator](#concept:nothrow-forward-iterator "26.11.2 Special memory concepts [special.mem.concepts]") O, [nothrow-sentinel-for](#concept:nothrow-sentinel-for "26.11.2 Special memory concepts [special.mem.concepts]")<O> S>
    requires [constructible_from](concept.constructible#concept:constructible_from "18.4.11 Concept 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](#uninitialized.move-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14076)

*Preconditions*: [ofirst, olast) does not overlap with ifirst+[0, n)[.](#uninitialized.move-8.sentence-1)

[9](#uninitialized.move-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](#uninitialized.move-10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14089)

[*Note [2](#uninitialized.move-note-2)*:

If an exception is thrown, some objects in the rangeifirst+[0, n) are left in a valid but unspecified state[.](#uninitialized.move-10.sentence-1)

â *end note*]

### [26.11.7](#uninitialized.fill) uninitialized_fill [[uninitialized.fill]](uninitialized.fill)

[ð](#lib:uninitialized_fill)

`template<class NoThrowForwardIterator, class T>
  constexpr void uninitialized_fill(NoThrowForwardIterator first,
                                    NoThrowForwardIterator last, const T& x);
`

[1](#uninitialized.fill-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14107)

*Effects*: Equivalent to:for (; first != last; ++first)::new (*voidify*(*first))typename iterator_traits<NoThrowForwardIterator>::value_type(x);

[ð](#lib:uninitialized_fill_)

`namespace ranges {
  template<[nothrow-forward-iterator](#concept:nothrow-forward-iterator "26.11.2 Special memory concepts [special.mem.concepts]") I, [nothrow-sentinel-for](#concept:nothrow-sentinel-for "26.11.2 Special memory concepts [special.mem.concepts]")<I> S, class T>
    requires [constructible_from](concept.constructible#concept:constructible_from "18.4.11 Concept constructible_­from [concept.constructible]")<iter_value_t<I>, const T&>
    constexpr I uninitialized_fill(I first, S last, const T& x);
  template<[nothrow-forward-range](#concept:nothrow-forward-range "26.11.2 Special memory concepts [special.mem.concepts]") R, class T>
    requires [constructible_from](concept.constructible#concept:constructible_from "18.4.11 Concept constructible_­from [concept.constructible]")<range_value_t<R>, const T&>
    constexpr borrowed_iterator_t<R> uninitialized_fill(R&& r, const T& x);
}
`

[2](#uninitialized.fill-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14130)

*Effects*: Equivalent to:for (; first != last; ++first)::new (*voidify*(*first)) remove_reference_t<iter_reference_t<I>>(x);return first;

[ð](#lib:uninitialized_fill_n)

`template<class NoThrowForwardIterator, class Size, class T>
  constexpr NoThrowForwardIterator
    uninitialized_fill_n(NoThrowForwardIterator first, Size n, const T& x);
`

[3](#uninitialized.fill-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14148)

*Effects*: Equivalent to:for (; n--; ++first)::new (*voidify*(*first))typename iterator_traits<NoThrowForwardIterator>::value_type(x);return first;

[ð](#lib:uninitialized_fill_n_)

`namespace ranges {
  template<[nothrow-forward-iterator](#concept:nothrow-forward-iterator "26.11.2 Special memory concepts [special.mem.concepts]") I, class T>
    requires [constructible_from](concept.constructible#concept:constructible_from "18.4.11 Concept constructible_­from [concept.constructible]")<iter_value_t<I>, const T&>
    constexpr I uninitialized_fill_n(I first, iter_difference_t<I> n, const T& x);
}
`

[4](#uninitialized.fill-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14169)

*Effects*: Equivalent to:return uninitialized_fill(counted_iterator(first, n), default_sentinel, x).base();

### [26.11.8](#specialized.construct) construct_at [[specialized.construct]](specialized.construct)

[ð](#lib:construct_at)

`template<class T, class... Args>
  constexpr T* construct_at(T* location, Args&&... args);

namespace ranges {
  template<class T, class... Args>
    constexpr T* construct_at(T* location, Args&&... args);
}
`

[1](#specialized.construct-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14191)

*Constraints*: is_unbounded_array_v<T> is false[.](#specialized.construct-1.sentence-1)

The expression ​::​new (declval<void*>()) T(declval<Args>()...) is well-formed when treated as an unevaluated operand ([[expr.context]](expr.context#term.unevaluated.operand "7.2.3 Context dependence"))[.](#specialized.construct-1.sentence-2)

[2](#specialized.construct-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14197)

*Mandates*: If is_array_v<T> is true, sizeof...(Args) is zero[.](#specialized.construct-2.sentence-1)

[3](#specialized.construct-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14201)

*Effects*: Equivalent to:if constexpr (is_array_v<T>)return ::new (*voidify*(*location)) T[1]();elsereturn ::new (*voidify*(*location)) T(std::forward<Args>(args)...);

### [26.11.9](#specialized.destroy) destroy [[specialized.destroy]](specialized.destroy)

[ð](#lib:destroy_at)

`template<class T>
  constexpr void destroy_at(T* location);
namespace ranges {
  template<[destructible](concept.destructible#concept:destructible "18.4.10 Concept destructible [concept.destructible]") T>
    constexpr void destroy_at(T* location) noexcept;
}
`

[1](#specialized.destroy-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14225)

*Effects*: 

- [(1.1)](#specialized.destroy-1.1)

  If T is an array type, equivalent to destroy(begin(*location), end(*location))[.](#specialized.destroy-1.1.sentence-1)

- [(1.2)](#specialized.destroy-1.2)

  Otherwise, equivalent to location->~T()[.](#specialized.destroy-1.2.sentence-1)

[ð](#lib:destroy)

`template<class NoThrowForwardIterator>
  constexpr void destroy(NoThrowForwardIterator first, NoThrowForwardIterator last);
`

[2](#specialized.destroy-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14242)

*Effects*: Equivalent to:for (; first != last; ++first) destroy_at(addressof(*first));

[ð](#lib:destroy_)

`namespace ranges {
  template<[nothrow-input-iterator](#concept:nothrow-input-iterator "26.11.2 Special memory concepts [special.mem.concepts]") I, [nothrow-sentinel-for](#concept:nothrow-sentinel-for "26.11.2 Special memory concepts [special.mem.concepts]")<I> S>
    requires [destructible](concept.destructible#concept:destructible "18.4.10 Concept destructible [concept.destructible]")<iter_value_t<I>>
    constexpr I destroy(I first, S last) noexcept;
  template<[nothrow-input-range](#concept:nothrow-input-range "26.11.2 Special memory concepts [special.mem.concepts]") R>
    requires [destructible](concept.destructible#concept:destructible "18.4.10 Concept destructible [concept.destructible]")<range_value_t<R>>
    constexpr borrowed_iterator_t<R> destroy(R&& r) noexcept;
}
`

[3](#specialized.destroy-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14264)

*Effects*: Equivalent to:for (; first != last; ++first) destroy_at(addressof(*first));return first;

[ð](#lib:destroy_n)

`template<class NoThrowForwardIterator, class Size>
  constexpr NoThrowForwardIterator destroy_n(NoThrowForwardIterator first, Size n);
`

[4](#specialized.destroy-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14281)

*Effects*: Equivalent to:for (; n > 0; (void)++first, --n) destroy_at(addressof(*first));return first;

[ð](#lib:destroy_n_)

`namespace ranges {
  template<[nothrow-input-iterator](#concept:nothrow-input-iterator "26.11.2 Special memory concepts [special.mem.concepts]") I>
    requires [destructible](concept.destructible#concept:destructible "18.4.10 Concept destructible [concept.destructible]")<iter_value_t<I>>
    constexpr I destroy_n(I first, iter_difference_t<I> n) noexcept;
}
`

[5](#specialized.destroy-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14301)

*Effects*: Equivalent to:return destroy(counted_iterator(std::move(first), n), default_sentinel).base();
