Namespaces
Variants
Views
Actions

std::{{{1}}}::assign_range

From cppreference.com
Revision as of 19:57, 12 July 2023 by Fruderica (Talk | contribs)

template< container-compatible-range<T> R >
void assign_range( R&& rg );
(since C++23)

Replaces elements in the container with a copy of each element in rg. Invalidate all references, pointers, and iterators referring to the elements of the container. Each iterator in the range rg is dereferenced exactly once.

The exposition only concept container-compatible-range is defined as below:

template<class R, class T>
concept container-compatible-range =    // exposition only
  ranges::input_range<R> && std::convertible_to<ranges::range_reference_t<R>, T>;

The behavior is undefined if rg overlaps with the container.

Contents

Parameters

rg - an input_range with reference type convertible to the element type of the container
Type requirements
-
std::assignable_from<T&, ranges​::​range_reference_t<R>> must be modeled. Otherwise, the program is ill-formed.
-
T must be EmplaceConstructible into the container from *ranges​::​begin(rg). Otherwise, the behavior is undefined.

Return value

(none)

Example

See also

inserts a range of elements
(public member function of std::{{{1}}})
assigns values to the container
(public member function of std::{{{1}}})