std::list<T,Allocator>::assign_range
Min standard notice:
Replaces elements in the container with a copy of each element in rg.
# Declarations
template< container-compatible-range<T> R >
void assign_range( R&& rg );
(since C++23)
# Parameters
rg: an input_range with reference type convertible to the element type of the container
# Return value
(none)
# Notes
Feature-test macro Value Std Feature __cpp_lib_containers_ranges 202202L (C++23) Ranges-aware construction and insertion
# Example
#include <algorithm>
#include <cassert>
#include <list>
#include <vector>
int main()
{
const auto source = std::vector{2, 7, 1};
auto destination = std::list{3, 1, 4};
#ifdef __cpp_lib_containers_ranges
destination.assign_range(source);
#else
destination.assign(source.cbegin(), source.cend());
#endif
assert(std::ranges::equal(source, destination));
}