MySQL 9.6.0
Source Code Documentation
mysql::containers::throwing Namespace Reference

Functions

template<class Map_or_set_t , class Source_iterator_t >
requires std::convertible_to< mysql::ranges::Iterator_value_type<Source_iterator_t>, mysql::ranges::Range_value_type<Map_or_set_t>>
void map_or_set_assign (Map_or_set_t &map_or_set, const Source_iterator_t &first, const std::sentinel_for< Source_iterator_t > auto &last)
 Replace the contents of container with that of the range given by the two iterators, minimizing memory allocations. More...
 

Function Documentation

◆ map_or_set_assign()

template<class Map_or_set_t , class Source_iterator_t >
requires std::convertible_to< mysql::ranges::Iterator_value_type<Source_iterator_t>, mysql::ranges::Range_value_type<Map_or_set_t>>
void mysql::containers::throwing::map_or_set_assign ( Map_or_set_t &  map_or_set,
const Source_iterator_t &  first,
const std::sentinel_for< Source_iterator_t > auto &  last 
)

Replace the contents of container with that of the range given by the two iterators, minimizing memory allocations.

This reuses existing nodes of the target container as far as possible, and allocates new ones only if the source has more nodes than the target container.

It does not copy the allocator.

Informally, this is to std::map what std::vector:assign is to std::vector.

Parameters
map_or_setContainer to overwrite.
firstIterator to first element of new contents.
lastIterator to last element of new contents.
Exceptions
std::bad_allocOut of memory. This can only occur if the source range has more elements than the container.