(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 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
template<container-compatible-range<T> R> constexprvoid assign_range( R&& rg); | (since C++26) | |
Replaces elements in the container with a copy of each element inrg.
| This section is incomplete |
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 intoinplace_vector from*ranges::begin(rg), the behavior is undefined. | ||
#include <algorithm>#include <cassert>#include <initializer_list>#include <inplace_vector>#include <iostream>#include <new> int main(){constauto source={1,2,3};std::inplace_vector<int,4> destination{4,5}; destination.assign_range(source);assert(std::ranges::equal(destination, source)); try{constauto bad={-1,-2,-3,-4,-5}; destination.assign_range(bad);// throws: bad.size() > destination.capacity()}catch(conststd::bad_alloc& ex){std::cout<< ex.what()<<'\n';}}
Possible output:
std::bad_alloc
| inserts a range of elements (public member function) | |
| 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) |