std::flat_m...lat_multimap(3)
π NAME
std::flat_multimap::flat_multimap β std::flat_multimap::flat_multimap
okay so real talk, bestie: you're in the C++ Standard Libary section of the manual π
and this is the constructor page for std::flat_multimap. yes, all twenty-eight of them. buckle up π
β¨ Synopsis
every single one of these is (since C++23), no cap. here they all are, in order, exactly as the standard spells them:
flat_multimap() (1)
: flat_multimap(key_compare()) { }
template< class Allocator > (2)
flat_multimap( const flat_multimap&, const Allocator& alloc );
template< class Allocator > (3)
flat_multimap( flat_multimap&&, const Allocator& alloc );
flat_multimap( key_container_type key_cont, mapped_container_type
mapped_cont, (4)
const key_compare& comp = key_compare() );
template< class Allocator >
flat_multimap( const key_container_type& key_cont, (5)
const mapped_container_type& mapped_cont,
const Allocator& alloc );
template< class Allocator >
flat_multimap( const key_container_type& key_cont, (6)
const mapped_container_type& mapped_cont,
const key_compare& comp, const Allocator& alloc );
flat_multimap( std::sorted_equivalent_t, key_container_type
key_cont,
(7)
mapped_container_type mapped_cont,
const key_compare& comp = key_compare() );
template< class Allocator >
flat_multimap( std::sorted_equivalent_t, const
key_container_type& key_cont, (8)
const mapped_container_type& mapped_cont, const
Allocator& alloc );
template< class Allocator >
flat_multimap( std::sorted_equivalent_t, const
key_container_type& key_cont, (9)
const mapped_container_type& mapped_cont,
const key_compare& comp, const Allocator& alloc );
explicit flat_multimap( const key_compare& comp ) (10)
: c(), compare(comp) { }
template< class Allocator > (11)
flat_multimap( const key_compare& comp, const Allocator& alloc );
template< class Allocator > (12)
explicit flat_multimap( const Allocator& alloc );
template< class InputIter >
flat_multimap( InputIter first, InputIter last, (13)
const key_compare& comp = key_compare() )
: c(), compare(comp);
template< class InputIter, class Allocator >
flat_multimap( InputIter first, InputIter last, (14)
const key_compare& comp, const Allocator& alloc );
template< class InputIter, class Allocator >
flat_multimap( InputIter first, InputIter last, const Allocator& (15)
alloc );
template< container-compatible-range<value_type> R >
flat_multimap( std::from_range_t, R&& rg, const key_compare& comp (16)
)
: flat_multimap(comp);
template< container-compatible-range<value_type> R >
flat_multimap( std::from_range_t fr, R&& rg ) (17)
: flat_multimap(fr, std::forward<R>(rg), key_compare()) { }
template< container-compatible-range<value_type> R, class
Allocator > (18)
flat_multimap( std::from_range_t, R&& rg, const Allocator& alloc
);
template< container-compatible-range<value_type> R, class
Allocator >
flat_multimap( std::from_range_t, R&& rg, const key_compare& (19)
comp,
const Allocator& alloc );
template< class InputIter >
flat_multimap( std::sorted_equivalent_t s, InputIter first,
InputIter last, (20)
const key_compare& comp = key_compare() )
: c(), compare(comp);
template< class InputIter, class Allocator >
flat_multimap( std::sorted_equivalent_t s, InputIter first, (21)
InputIter last,
const key_compare& comp, const Allocator& alloc );
template< class InputIter, class Allocator >
flat_multimap( std::sorted_equivalent_t s, InputIter first, (22)
InputIter last,
const Allocator& alloc );
flat_multimap( std::initializer_list<value_type> init,
const key_compare& comp = key_compare() ) (23)
: flat_multimap(init.begin(), init.end(), comp) { }
template< class Allocator >
flat_multimap( std::initializer_list<value_type> init, const (24)
key_compare& comp,
const Allocator& alloc );
template< class Allocator >
flat_multimap( std::initializer_list<value_type> init, const (25)
Allocator& alloc );
flat_multimap( std::sorted_equivalent_t s,
std::initializer_list<value_type> init,
(26)
const key_compare& comp = key_compare() )
: flat_multimap(s, init.begin(), init.end(), comp) { }
template< class Allocator >
flat_multimap( std::sorted_equivalent_t s, (27)
std::initializer_list<value_type> init,
const key_compare& comp, const Allocator& alloc );
template< class Allocator >
flat_multimap( std::sorted_equivalent_t s, (28)
std::initializer_list<value_type> init,
const Allocator& alloc );
π DESCRIPTION
okay so what do these bad boys actually do? they construct a new container adaptor from a whole bunch of different data sources, and optionally they use a user-supplied comparison function object comp and/or an allocator alloc. it's giving β¨customizationβ¨. here's the breakdown, one overload at a time, no skips π«Ά
(1)β the default constructor, the lowkey main character. constructs an empty container adaptor π£(2)β the copy constructor. constructscwith the copy of the contents ofother.c, andcomparewithother.compare. see the allocator usage note below π(3)β the move constructor. constructs the container adaptor with the contents ofotherusing move semantics. see the allocator usage note below π(4)β first, initializesc.keyswithstd::move(key_cont),c.valueswithstd::move(mapped_cont), andcomparewithcomp. then it sorts the underlying range[begin(), end())with respect tovalue_comp(). yes, it sorts. that's the whole vibe π₯(5)β same as(4), equivalent toflat_multimap(key_cont, mapped_cont);. see the allocator usage note below π(6)β same as(4), equivalent toflat_multimap(key_cont, mapped_cont, comp);. see the allocator usage note below π(7)β initializesc.keyswithstd::move(key_cont),c.valueswithstd::move(mapped_cont), andcomparewithcomp. and that's it β no sorting here, because you already promised it's sorted (that's whatstd::sorted_equivalent_tmeans, iykyk) πΈ(8)β same as(7), equivalent toflat_multimap(s, key_cont, mapped_cont);. see the allocator usage note below π(9)β same as(7), equivalent toflat_multimap(s, key_cont, mapped_cont, comp);. see the allocator usage note below π(10)β constructs an empty container adaptor π£(11,12)β constructs an empty container adaptor. see the 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 the allocator usage note below π(16)β constructs the container adaptor with the contents of the rangerg. first, it uses(10)as delegating constructor. then it initializescwith the contents ofrgas if byinsert_range(std::forward<R>(rg));π(17)β same as(16), using it as delegating constructor.(18,19)β same as(16). see the allocator usage note below π(20)β constructs the underlying containers with the contents of the range[first, last)as if byinsert(first, last). π¦(21,22)β same as(20). see the allocator usage note below π(23)β an initializer-list constructor. constructs the underlying container with the contents of the initializer listinit, using(13)as delegating constructor π(24,25)β same as(23). see the allocator usage note below π(26)β an initializer-list constructor. constructs the underlying container with the contents of the initializer listinit, using(20)as delegating constructor π(27,28)β same as(26). see the allocator usage note below π
β οΈ note for overloads (13-15, 20-22), bestie, listen to me: if [first, last) is not a valid range, the behavior is undefined. not "oops it throws," not "it'll be fine" β undefined. don't do it π
πΈ Parameters
key_contβ a container to be used as source to initialize the underlying keys containermapped_contβ a container to be used as source to initialize the underlying values containerotherβ anotherflat_multimapto be used as source to initialize the elements of the underlying containers withallocβ an allocator to use for all memory allocations of the underlying containerscompβ a function object to be used for all comparisons of keysfirst, lastβ a range to copy the elements frominitβ an initializer list to initialize the elements of the underlying containers withrgβ a container compatible range (that is, aninput_rangewhose elements are convertible tovalue_type) to be used as source to initialize the underlying containersfrβ a disambiguation tag that indicates that the contained member should be range constructedsβ a disambiguation tag that indicates that the input sequence is sorted with respect tovalue_comp()
π Type requirements
InputItmust meet the requirements ofLegacyInputIterator.Comparemust meet the requirements ofCompare.Allocatormust meet the requirements ofAllocator.
(and yes, the synopsis spells it InputIter and this list spells it InputIt β that's literally how the page has it, we don't fix, we report π)
π COMPLEXITY
okay bestie, this is the "how long is this gonna take" section and it's LONG, so buckle up π Every overload is numbered, so match the numbers to the overload list from before, mwah.
- 1) Constant. literally nothing happens, slay.
- 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 N if
contis sorted with respect tovalue_comp(), otherwise π(NΒ·log(N)), where N is the value ofkey_cont.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. iconic behaviour, no notes.
- 13β15) Linear in N if the input range
[first, last)is sorted with respect tovalue_comp(), otherwise π(NΒ·log(N)), where N is the value ofkey_cont.size()before this call. - 16β19) Linear in N if the input range
rgis sorted with respect tovalue_comp(), otherwise π(NΒ·log(N)), where N is the value ofkey_cont.size()before this call. - 20β22) Linear in size of
[first, last). - 23β25) Linear in N if the elements of
initare sorted with respect tovalue_comp(), otherwise π(NΒ·log(N)), where N is the value ofkey_cont.size()before this call. - 26β28) Linear in size of
init.
ngl the whole "sorted with respect to value_comp()" thing is the main character of this section β if it's sorted you get the cheap linear path, if it's not, you're paying that log tax π
π EXCEPTIONS
Calls to Allocator::allocate may throw. that's it, that's the tea π« (so like, be ready, bestie).
π NOTES
After container move construction (overload (3)), 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. iykyk β¨
π¦ EXAMPLE
This section is incomplete
Reason: no example
not me showing up with zero examples π it's giving "trust me bro", but okay, we move.
π SEE ALSO
operator=β assigns values to the container adaptor (public member function)
Category: Todo no example
and that's the whole page, bestie!! πβ¨ source/version: http://cppreference.com, dated 2024.06.10, for std::flat_m...lat_multimap(3) β go forth and construct your flat multimaps, ily, bye π
π«Άπ
π¦ 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