23 General utilities library [utilities]
Throughout this subclause,
the names of template parameters are used to express type requirements
. If an algorithm's template parameter is named
InputIterator,
the template argument shall satisfy the requirements
of an input iterator (
[input.iterators])
.If an algorithm's template parameter is named
ForwardIterator,
the template argument shall satisfy the requirements
of a forward iterator (
[forward.iterators]), and
is required to have the property that no exceptions are thrown
from increment, assignment, comparison, or indirection through valid iterators
.
Unless otherwise specified,
if an exception is thrown in the following algorithms there are no effects
.template <class T> constexpr T* addressof(T& r) noexcept;
Returns: The actual address of the object or function referenced by
r, even in the
presence of an overloaded
operator&. Remarks: An expression
addressof(E)
is a constant subexpression (
[defns.const.subexpr])
if
E is an lvalue constant subexpression
. template <class ForwardIterator>
void uninitialized_default_construct(ForwardIterator first, ForwardIterator last);
Effects:
Equivalent to:
for (; first != last; ++first)
::new (static_cast<void*>(addressof(*first)))
typename iterator_traits<ForwardIterator>::value_type;
template <class ForwardIterator, class Size>
ForwardIterator uninitialized_default_construct_n(ForwardIterator first, Size n);
Effects:
Equivalent to:
for (; n>0; (void)++first, --n)
::new (static_cast<void*>(addressof(*first)))
typename iterator_traits<ForwardIterator>::value_type;
return first;
template <class ForwardIterator>
void uninitialized_value_construct(ForwardIterator first, ForwardIterator last);
Effects:
Equivalent to:
for (; first != last; ++first)
::new (static_cast<void*>(addressof(*first)))
typename iterator_traits<ForwardIterator>::value_type();
template <class ForwardIterator, class Size>
ForwardIterator uninitialized_value_construct_n(ForwardIterator first, Size n);
Effects:
Equivalent to:
for (; n>0; (void)++first, --n)
::new (static_cast<void*>(addressof(*first)))
typename iterator_traits<ForwardIterator>::value_type();
return first;
template <class InputIterator, class ForwardIterator>
ForwardIterator uninitialized_copy(InputIterator first, InputIterator last,
ForwardIterator result);
Effects:
As if by:
for (; first != last; ++result, (void) ++first)
::new (static_cast<void*>(addressof(*result)))
typename iterator_traits<ForwardIterator>::value_type(*first);
template <class InputIterator, class Size, class ForwardIterator>
ForwardIterator uninitialized_copy_n(InputIterator first, Size n,
ForwardIterator result);
Effects:
As if by:
for ( ; n > 0; ++result, (void) ++first, --n) {
::new (static_cast<void*>(addressof(*result)))
typename iterator_traits<ForwardIterator>::value_type(*first);
}
template <class InputIterator, class ForwardIterator>
ForwardIterator uninitialized_move(InputIterator first, InputIterator last,
ForwardIterator result);
Effects:
Equivalent to:
for (; first != last; (void)++result, ++first)
::new (static_cast<void*>(addressof(*result)))
typename iterator_traits<ForwardIterator>::value_type(std::move(*first));
return result;
Remarks:
If an exception is thrown, some objects in the range
[first, last)
are left in a valid but unspecified state
. template <class InputIterator, class Size, class ForwardIterator>
pair<InputIterator, ForwardIterator>
uninitialized_move_n(InputIterator first, Size n, ForwardIterator result);
Effects:
Equivalent to:
for (; n > 0; ++result, (void) ++first, --n)
::new (static_cast<void*>(addressof(*result)))
typename iterator_traits<ForwardIterator>::value_type(std::move(*first));
return {first,result};
Remarks:
If an exception is thrown, some objects in the range
[first, std::next(first,n))
are left in a valid but unspecified state
. template <class ForwardIterator, class T>
void uninitialized_fill(ForwardIterator first, ForwardIterator last,
const T& x);
Effects:
As if by:
for (; first != last; ++first)
::new (static_cast<void*>(addressof(*first)))
typename iterator_traits<ForwardIterator>::value_type(x);
template <class ForwardIterator, class Size, class T>
ForwardIterator uninitialized_fill_n(ForwardIterator first, Size n, const T& x);
Effects:
As if by:
for (; n--; ++first)
::new (static_cast<void*>(addressof(*first)))
typename iterator_traits<ForwardIterator>::value_type(x);
return first;
template <class T>
void destroy_at(T* location);
Effects:
Equivalent to:
location->~T();
template <class ForwardIterator>
void destroy(ForwardIterator first, ForwardIterator last);
Effects:
Equivalent to:
for (; first!=last; ++first)
destroy_at(addressof(*first));
template <class ForwardIterator, class Size>
ForwardIterator destroy_n(ForwardIterator first, Size n);
Effects:
Equivalent to:
for (; n > 0; (void)++first, --n)
destroy_at(addressof(*first));
return first;