[specialized.destroy] # 26 Algorithms library [[algorithms]](./#algorithms) ## 26.11 Specialized algorithms [[specialized.algorithms]](specialized.algorithms#specialized.destroy) ### 26.11.9 destroy [specialized.destroy] [🔗](#lib:destroy_at) `template 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](#1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L14225) *Effects*: - [(1.1)](#1.1) If T is an array type, equivalent to destroy(begin(*location), end(*location))[.](#1.1.sentence-1) - [(1.2)](#1.2) Otherwise, equivalent to location->~T()[.](#1.2.sentence-1) [🔗](#lib:destroy) `template constexpr void destroy(NoThrowForwardIterator first, NoThrowForwardIterator last); ` [2](#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](special.mem.concepts#concept:nothrow-input-iterator "26.11.2 Special memory concepts [special.mem.concepts]") I, [nothrow-sentinel-for](special.mem.concepts#concept:nothrow-sentinel-for "26.11.2 Special memory concepts [special.mem.concepts]") S> requires [destructible](concept.destructible#concept:destructible "18.4.10 Concept destructible [concept.destructible]")> constexpr I destroy(I first, S last) noexcept; template<[nothrow-input-range](special.mem.concepts#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]")> constexpr borrowed_iterator_t destroy(R&& r) noexcept; } ` [3](#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 constexpr NoThrowForwardIterator destroy_n(NoThrowForwardIterator first, Size n); ` [4](#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](special.mem.concepts#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]")> constexpr I destroy_n(I first, iter_difference_t n) noexcept; } ` [5](#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();