std::flat_m...lat_multiset(3)
๐ NAME ๐
std::flat_multiset::flat_multiset โ std::flat_multiset::flat_multiset
this is the std::flat_m...lat_multiset(3) page from the C++ Standard Libary (yes, โLibaryโ, thatโs the headerโs typo, weโre keeping the chaos), and itโs all about constructors for std::flat_multiset. there are literally 28 overloads. twenty-eight. iconic overload count, no cap.
โจ Synopsis โจ
every overload here is (since C++23), and the lineup is long enough to need a snack. here it is, verbatim:
flat_multiset() (1)
(since C++23)
: flat_multiset(key_compare()) { }
template< class Allocator >
flat_multiset( const flat_multiset& other, const Allocator& alloc (2)
(since C++23)
);
template< class Allocator > (3)
(since C++23)
flat_multiset( flat_multiset&& other, const Allocator& alloc );
explicit flat_multiset( container_type cont,
const key_compare& comp = key_compare() (4)
(since C++23)
);
template< class Allocator >
flat_multiset( const container_type& cont, const Allocator& alloc (5)
(since C++23)
);
template< class Allocator >
flat_multiset( const container_type& cont, const key_compare& (6)
(since C++23)
comp,
const Allocator& alloc );
flat_multiset( std::sorted_equivalent_t s, container_type cont,
const key_compare& comp = key_compare() ) (7)
(since C++23)
: c(std::move(cont)), compare(comp) { }
template< class Allocator >
flat_multiset( std::sorted_equivalent_t s, const container_type& (8)
(since C++23)
cont,
const Allocator& alloc );
template< class Allocator >
flat_multiset( std::sorted_equivalent_t s, const container_type& (9)
(since C++23)
cont,
const key_compare& comp, const Allocator& alloc );
explicit flat_multiset( const key_compare& comp )
(10) (since C++23)
: c(), compare(comp) { }
template< class Allocator >
(11) (since C++23)
flat_multiset( const key_compare& comp, const Allocator& alloc );
template< class Allocator >
(12) (since C++23)
explicit flat_multiset( const Allocator& alloc );
template< class InputIter >
flat_multiset( InputIter first, InputIter last,
(13) (since C++23)
const key_compare& comp = key_compare() )
: c(), compare(comp);
template< class InputIter, class Allocator >
flat_multiset( InputIter first, InputIter last,
(14) (since C++23)
const key_compare& comp, const Allocator& alloc );
template< class InputIter, class Allocator >
flat_multiset( InputIter first, InputIter last, const Allocator&
(15) (since C++23)
alloc );
template< container-compatible-range<value_type> R >
flat_multiset( std::from_range_t, R&& rg, const key_compare& comp
(16) (since C++23)
)
: flat_multiset(comp);
template< container-compatible-range<value_type> R >
flat_multiset( std::from_range_t fr, R&& rg )
(17) (since C++23)
: flat_multiset( fr, std::forward<R>(rg), key_compare() ) { }
template< container-compatible-range<value_type> R, class
Allocator >
(18) (since C++23)
flat_multiset( std::from_range_t, R&& rg, const Allocator& alloc
);
template< container-compatible-range<value_type> R, class
Allocator >
flat_multiset( std::from_range_t, R&& rg, const key_compare&
(19) (since C++23)
comp,
const Allocator& alloc );
template< class InputIter >
flat_multiset( std::sorted_equivalent_t s, InputIter first,
InputIter last,
(20) (since C++23)
const key_compare& comp = key_compare() )
: c(first, last), compare(comp) { }
template< class InputIter, class Allocator >
flat_multiset( std::sorted_equivalent_t s, InputIter first,
(21) (since C++23)
InputIter last,
const key_compare& comp, const Allocator& alloc );
template< class InputIter, class Allocator >
flat_multiset( std::sorted_equivalent_t s, InputIter first,
(22) (since C++23)
InputIter last,
const Allocator& alloc );
flat_multiset( std::initializer_list<value_type> init,
const key_compare& comp = key_compare() )
(23) (since C++23)
: flat_multiset(init.begin(), init.end(), comp) { }
template< class Allocator >
flat_multiset( std::initializer_list<value_type> init, const
(24) (since C++23)
key_compare& comp,
const Allocator& alloc );
template< class Allocator >
flat_multiset( std::initializer_list<value_type> init, const
(25) (since C++23)
Allocator& alloc );
flat_multiset( std::sorted_equivalent_t s,
std::initializer_list<value_type> init,
(26)
(since C++23)
const key_compare& comp = key_compare() )
: flat_multiset(s, init.begin(), init.end(), comp) { }
template< class Allocator >
flat_multiset( std::sorted_equivalent_t s,
(27) (since C++23)
std::initializer_list<value_type> init,
const key_compare& comp, const Allocator& alloc );
template< class Allocator >
flat_multiset( std::sorted_equivalent_t s,
(28) (since C++23)
std::initializer_list<value_type> init,
const Allocator& alloc );
okay so thatโs the whole roster. now letโs actually talk about what each one does, bestie.
๐ Description ๐
Constructs a new container adaptor from a variety of data sources and optionally provided comparison function object comp and/or allocator alloc. lowkey a constructor buffet. letโs go one by one.
- (1) a default constructor. constructs an empty container adaptor. clean, simple, no notes.
- (2) a copy constructor. constructs
cwith the copy of the contents ofother.candcomparewithother.compare. see allocator usage note below. - (3) a move constructor. constructs the container adaptor with the contents of
otherusing move semantics. see allocator usage note below. - (4) constructs the underlying container with the contents of the container
cont. first, initializescwithstd::move(cont)andcomparewithcomp. then sorts thecwith respect tocomp. okay so it moves, then sorts. got it. - (5) same as (4), equivalent to
flat_multiset(cont);. see allocator usage note below. - (6) same as (4), equivalent to
flat_multiset(cont, comp);. see allocator usage note below. - (7) constructs the underlying container with the contents of the other container
cont. initializescwithstd::move(cont)andcomparewithcomp. this is the sorted-equivalent-tag one, so itโs already promising the input sequence is sorted. fancy. - (8) same as (7), equivalent to
flat_multiset(s, cont);. see allocator usage note below. - (9) same as (7), equivalent to
flat_multiset(s, cont, comp);. see allocator usage note below. - (10) constructs an empty container adaptor. the explicit
compone. it literally initializes: c(), compare(comp) { }. empty but opinionated. - (11), (12) constructs an empty container adaptor. see allocator usage note below.
- (13) constructs the container adaptor with the contents of the range
[first, last), equivalent toinsert(first, last);. - (14), (15) same as (13). see allocator usage note below.
- (16) constructs the container adaptor with the contents of the range
rg. first, uses (10) as delegating constructor. then initializescwith the contents ofrgas if byinsert_range(std::forward<R>(rg));. - (17) same as (16) using it as delegating constructor. yes,
fris the tag,rgis the range, itโs all happening. - (18), (19) same as (16). see allocator usage note below.
- (20) constructs the underlying container with the contents of the range
[first, last). initializescwithc(first, last)andcomparewithcompare(comp). thatโs the sorted-tag + iterator-range combo, bestie. - (21), (22) same as (20). see allocator usage note below.
- (23) an initializer-list constructor. constructs the underlying container with the contents of the initializer list
init, using (13) as delegating constructor. - (24), (25) same as (23). see allocator usage note below.
- (26) an initializer-list constructor. constructs the underlying container with the contents of the initializer list
init, using (20) as delegating constructor. - (27), (28) Save as (26). see allocator usage note below. (yes, โSave asโ, thatโs what the page says, weโre not editing the sacred text.)
โ ๏ธ note for overloads (13-15,20-22): if [first, last) is not a valid range, the behavior is undefined. like, undefined undefined. do not play with that range unless you mean it.
๐ธ Parameters ๐ธ
contโ a container to be used as source to initialize the underlying container.otherโ anotherflat_multisetto be used as source to initialize the elements of the underlying container with.allocโ an allocator to use for all memory allocations of the underlying container.compโ a function object to be used for all comparisons of keys.first,lastโ a range to copy the elements from.initโ an initializer list to initialize the elements of the underlying container with.rgโ a container compatible range (that is, aninput_rangewhose elements are convertible tovalue_type) to be used as source to initialize the underlying container.frโ a disambiguation tag that indicates that the contained member should be range constructed.sโ a disambiguation tag that indicates that the input sequence is sorted with respect tocompare.
๐ฆ Type requirements ๐ฆ
InputItmust meet the requirements ofLegacyInputIterator.Comparemust meet the requirements ofCompare.Allocatormust meet the requirements ofAllocator.
๐ฆ COMPLEXITY ๐ฆ
okay bestie, hereโs the timing tea โ โ every numbered vibe below is straight from the source, no cap:
- 1) Constant. literally no drama.
- 2) Linear in size of
other. - 3) Same as the corresponding move-constructor of the wrapped container, i.e. constant or linear in size of
cont. - 4-6) Linear in
\(\scriptsize N\)Nifcontis sorted with respect tocompare, otherwise\(\scriptsize \mathcal{O}(N\cdot\log{(N)})\)๐(Nยทlog(N)), where\(\scriptsize N\)Nis the value ofcont.size()before this call. - 7-9) Same as the corresponding move-constructor of the wrapped container, i.e. constant or linear in size of
cont. - 10-12) Constant.
- 13-15) Linear in
\(\scriptsize N\)Nif the input range[first, last)is sorted with respect tocompare, otherwise\(\scriptsize \mathcal{O}(N\cdot\log{(N)})\)๐(Nยทlog(N)), where\(\scriptsize N\)Nis the value ofcont.size()before this call. - 16-19) Linear in
\(\scriptsize N\)Nif the input rangergis sorted with respect tocompare, otherwise\(\scriptsize \mathcal{O}(N\cdot\log{(N)})\)๐(Nยทlog(N)), where\(\scriptsize N\)Nis the value ofcont.size()before this call. - 20-22) Linear in size of
[first, last). - 23-25) Linear in
\(\scriptsize N\)Nif the elements ofinitare sorted with respect tocompare, otherwise\(\scriptsize \mathcal{O}(N\cdot\log{(N)})\)๐(Nยทlog(N)), where\(\scriptsize N\)Nis the value ofcont.size()before this call. - 26-28) Linear in size of
init.
๐ญ EXCEPTIONS ๐ญ
Calls to Allocator::allocate may throw. so yeah, allocation can absolutely throw hands โ keep that in mind ๐ซถ
๐ NOTES ๐
After container move construction (overload (3,16-19)), references, pointers, and iterators (other than the end iterator) to other remain valid, but refer to elements that are now in *this. The current standard makes this guarantee via the blanket statement in [container.reqmts]/67, and a more direct guarantee is under consideration via LWG issue 2321.
bestie this is the โyour stuff survived the move but it lives in a new address nowโ situation ๐
๐ธ EXAMPLE ๐ธ
This section is incomplete
Reason: no example
sorry bestie, sheโs giving โempty group chatโ energy โ no example here ๐ญ
๐ SEE ALSO ๐
operator=โ assigns values to the container adaptor (public member function)
Category:
- Todo no example
okay thatโs the whole vibe check ๐ signing off with source/version cppreference.com and date 2024.06.10, for the page std::flat_m...lat_multiset(3) โ slay, bye bestie ๐โจ๐ฆ
๐ฆ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 ยท MIT
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms