Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
std::list::assign_range(3)    C++ Standard Libary   std::list::assign_range(3)

NAME
       std::list::assign_range - std::list::assign_range

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

	  Replaces  elements  in  the container	with a copy of each element in
       rg.

	  Invalidates all iterators, pointers and references to	the elements.

	  Each iterator	in the range rg	is dereferenced	exactly	once.

	  The behavior is undefined if rg overlaps with	the container.

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 mod-
       eled. Otherwise,
	  the program is ill-formed.
	  -
	  T must be EmplaceConstructible into the container from  *ranges::be-
       gin(rg).
	  Otherwise, the behavior is undefined.

Return value
	  (none)

Notes
	      Feature-test macro       Value	Std		      Feature
	  __cpp_lib_containers_ranges  202202L	(C++23)	Ranges-aware construc-
       tion and	insertion

Example
       // Run this code

	#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));
	}

See also
	  insert_range	inserts	a range	of elements
	  (C++23)	(public	member function)
	  prepend_range	adds a range of	elements to the	beginning
	  (C++23)	(public	member function)
	  append_range	adds a range of	elements to the	end
	  (C++23)	(public	member function)
	  assign	assigns	values to the container
			(public	member function)

http://cppreference.com		  2024.06.10	    std::list::assign_range(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::list::assign_range&sektion=3&manpath=FreeBSD+Ports+15.1.quarterly>

home | help