(C++17) | ||||
Sequence | ||||
(C++11) | ||||
(C++26) | ||||
(C++26) | ||||
(C++11) | ||||
Associative | ||||
Unordered associative | ||||
(C++11) | ||||
(C++11) | ||||
(C++11) | ||||
(C++11) | ||||
Adaptors | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
Views | ||||
(C++20) | ||||
(C++23) | ||||
Tables | ||||
Iterator invalidation | ||||
Member function table | ||||
Non-member function table |
Member types | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Member functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Non-member functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Deduction guides(C++17) |
template<container-compatible-range<T> R> constexprvoid assign_range( R&& rg); | (since C++23) | |
Replaces elements in the container with a copy of each element inrg.
All iterators (including theend()
iterator) and all references to the elements are invalidated.
Each iterator in the rangerg is dereferenced exactly once.
Ifrg overlaps with*this, the behavior is undefined.
Contents |
rg | - | aninput_range with reference type convertible to the element type of the container | ||||
Type requirements | ||||||
-Ifstd::assignable_from<T&,ranges::range_reference_t<R>> is not modeled, the program is ill-formed. | ||||||
-IfT is notEmplaceConstructible intovector from*ranges::begin(rg), the behavior is undefined. | ||||||
-If any of the following conditions is satisfied, andT is notMoveInsertable intovector , the behavior is undefined:
|
Feature-test macro | Value | Std | Feature |
---|---|---|---|
__cpp_lib_containers_ranges | 202202L | (C++23) | Ranges-aware construction and insertion |
#include <algorithm>#include <cassert>#include <vector>#include <list> int main(){constauto source=std::list{2,7,1};auto destination=std::vector{3,1,4};#ifdef __cpp_lib_containers_ranges destination.assign_range(source);#else destination.assign(source.cbegin(), source.cend());#endifassert(std::ranges::equal(source, destination));}
(C++23) | inserts a range of elements (public member function) |
(C++23) | adds a range of elements to the end (public member function) |
assigns values to the container (public member function) | |
assigns values to the container (public member function) |