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

FreeBSD Manual Pages

  
 
  

home | help
std::flat_m...set::replace(3) C++ Standard Libarystd::flat_m...set::replace(3)

NAME
       std::flat_multiset::replace - std::flat_multiset::replace

Synopsis
	  void replace(	container_type&& cont );  (since C++23)

	  Replaces   the   underlying	container   c.	 Equivalent  to:  c  =
       std::move(cont);.

	  The elements of cont must be sorted with respect to compare.	Other-
       wise, the behavior
	  is undefined.

Parameters
	  cont	-  a  sorted  container	 of type KeyContainer, the contents of
       which will be moved
		 into *this

Return value
	  (none)

Complexity
	  Equals to complexity of std::move applied to adapted container.

Example
       // Run this code

	#include <algorithm>
	#include <cassert>
	#include <flat_set>
	#include <print>
	#include <vector>

	int main()
	{
	    std::vector<int> keys{1, 2,	3};
	    assert(std::ranges::is_sorted(keys));

	    std::flat_multiset<int> set;
	    assert(set.empty());

	    set.replace(keys);
	    assert(set.size() == 3);
	    assert(keys.empty());

	    std::println("{}", set); //	set.keys()
	}

Output:
	[1, 2, 3]

See also
	  extract extracts the underlying container
		  (public member function)

http://cppreference.com		  2024.06.10	 std::flat_m...set::replace(3)

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

home | help