std::flat_m...lat_multimap(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– 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. constructs c with the copy of the contents of other.c, and compare with other.compare. see the allocator usage note below πŸ’œ
  • (3) β€” the move constructor. constructs the container adaptor with the contents of other using move semantics. see the allocator usage note below πŸ’œ
  • (4) β€” first, initializes c.keys with std::move(key_cont), c.values with std::move(mapped_cont), and compare with comp. then it sorts the underlying range [begin(), end()) with respect to value_comp(). yes, it sorts. that's the whole vibe πŸ”₯
  • (5) β€” same as (4), equivalent to flat_multimap(key_cont, mapped_cont);. see the allocator usage note below πŸ’œ
  • (6) β€” same as (4), equivalent to flat_multimap(key_cont, mapped_cont, comp);. see the allocator usage note below πŸ’œ
  • (7) β€” initializes c.keys with std::move(key_cont), c.values with std::move(mapped_cont), and compare with comp. and that's it β€” no sorting here, because you already promised it's sorted (that's what std::sorted_equivalent_t means, iykyk) 🌸
  • (8) β€” same as (7), equivalent to flat_multimap(s, key_cont, mapped_cont);. see the allocator usage note below πŸ’œ
  • (9) β€” same as (7), equivalent to flat_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 to insert(first, last); πŸ¦‹
  • (14,15) β€” same as (13). see the allocator usage note below πŸ’œ
  • (16) β€” constructs the container adaptor with the contents of the range rg. first, it uses (10) as delegating constructor. then it initializes c with the contents of rg as if by insert_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 by insert(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 list init, 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 list init, 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 container
  • mapped_cont β€” a container to be used as source to initialize the underlying values container
  • other β€” another flat_multimap to be used as source to initialize the elements of the underlying containers with
  • alloc β€” an allocator to use for all memory allocations of the underlying containers
  • 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 containers with
  • rg β€” a container compatible range (that is, an input_range whose elements are convertible to value_type) to be used as source to initialize the underlying containers
  • 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 to value_comp()

πŸŽ€ Type requirements

  • InputIt must meet the requirements of LegacyInputIterator.
  • Compare must meet the requirements of Compare.
  • Allocator must meet the requirements of Allocator.

(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 cont is sorted with respect to value_comp(), otherwise π“ž(NΒ·log(N)), where N is the value of key_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 to value_comp(), otherwise π“ž(NΒ·log(N)), where N is the value of key_cont.size() before this call.
  • 16–19) Linear in N if the input range rg is sorted with respect to value_comp(), otherwise π“ž(NΒ·log(N)), where N is the value of key_cont.size() before this call.
  • 20–22) Linear in size of [first, last).
  • 23–25) Linear in N if the elements of init are sorted with respect to value_comp(), otherwise π“ž(NΒ·log(N)), where N is the value of key_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