Namespaces
Variants

std::flat_multimap<Key,T,Compare,KeyContainer,MappedContainer>::flat_multimap

From cppreference.com

[edit template]
 
 
 
 
flat_multimap()
    : flat_multimap(key_compare()) {}
(1) (since C++23)
flat_multimap( const flat_multimap& other );
(2) (since C++23)
flat_multimap( flat_multimap&& other );
(3) (since C++23)
explicit flat_multimap( const key_compare& comp )
    : c(), compare(comp) {}
(4) (since C++23)
flat_multimap( key_container_type key_cont,
               mapped_container_type mapped_cont,
               const key_compare& comp = key_compare() );
(5) (since C++23)
flat_multimap( std::sorted_equivalent_t,
               key_container_type key_cont,
               mapped_container_type mapped_cont,
               const key_compare& comp = key_compare() );
(6) (since C++23)
template< class InputIter >
flat_multimap( InputIter first, InputIter last,
               const key_compare& comp = key_compare() )
    : c(), compare(comp);
(7) (since C++23)
template< class InputIter >
flat_multimap( std::sorted_equivalent_t, InputIter first, InputIter last,
               const key_compare& comp = key_compare() )
    : c(), compare(comp);
(8) (since C++23)
template< container-compatible-range<value_type> R >
flat_multimap( std::from_range_t, R&& rg )
    : flat_multimap(std::from_range, std::forward<R>(rg), key_compare()) {}
(9) (since C++23)
template< container-compatible-range<value_type> R >
flat_multimap( std::from_range_t, R&& rg, const key_compare& comp )
    : flat_multimap(comp);
(10) (since C++23)
flat_multimap( std::initializer_list<value_type> init,
               const key_compare& comp = key_compare() )
    : flat_multimap(init.begin(), init.end(), comp) {}
(11) (since C++23)
flat_multimap( std::sorted_equivalent_t,
               std::initializer_list<value_type> init,
               const key_compare& comp = key_compare() )
    : flat_multimap(std::sorted_equivalent,
                    init.begin(), init.end(), comp) {}
(12) (since C++23)
Constructors with allocators
template< class Allocator >
explicit flat_multimap( const Allocator& alloc );
(1A) (since C++23)
template< class Allocator >
flat_multimap( const flat_multimap& other, const Allocator& alloc );
(2A) (since C++23)
template< class Allocator >
flat_multimap( flat_multimap&& other, const Allocator& alloc );
(3A) (since C++23)
template< class Allocator >
flat_multimap( const key_compare& comp, const Allocator& alloc );
(4A) (since C++23)
template< class Allocator >
flat_multimap( const key_container_type& key_cont,
               const mapped_container_type& mapped_cont,
               const Allocator& alloc );
(5A) (since C++23)
template< class Allocator >
flat_multimap( const key_container_type& key_cont,
               const mapped_container_type& mapped_cont,
               const key_compare& comp, const Allocator& alloc );
(5B) (since C++23)
template< class Allocator >
flat_multimap( std::sorted_equivalent_t,
               const key_container_type& key_cont,
               const mapped_container_type& mapped_cont,
               const Allocator& alloc );
(6A) (since C++23)
template< class Allocator >
flat_multimap( std::sorted_equivalent_t,
               const key_container_type& key_cont,
               const mapped_container_type& mapped_cont,
               const key_compare& comp, const Allocator& alloc );
(6B) (since C++23)
template< class InputIter, class Allocator >
flat_multimap( InputIter first, InputIter last, const Allocator& alloc );
(7A) (since C++23)
template< class InputIter, class Allocator >
flat_multimap( InputIter first, InputIter last,
               const key_compare& comp, const Allocator& alloc );
(7B) (since C++23)
template< class InputIter, class Allocator >
flat_multimap( std::sorted_equivalent_t, InputIter first, InputIter last,
               const Allocator& alloc );
(8A) (since C++23)
template< class InputIter, class Allocator >
flat_multimap( std::sorted_equivalent_t, InputIter first, InputIter last,
               const key_compare& comp, const Allocator& alloc );
(8B) (since C++23)
template< container-compatible-range<value_type> R, class Allocator >
flat_multimap( std::from_range_t, R&& rg, const Allocator& alloc );
(9A) (since C++23)
template< container-compatible-range<value_type> R, class Allocator >
flat_multimap( std::from_range_t, R&& rg, const key_compare& comp,
               const Allocator& alloc );
(10A) (since C++23)
template< class Allocator >
flat_multimap( std::initializer_list<value_type> init,
               const Allocator& alloc );
(11A) (since C++23)
template< class Allocator >
flat_multimap( std::initializer_list<value_type> init,
               const key_compare& comp, const Allocator& alloc );
(11B) (since C++23)
template< class Allocator >
flat_multimap( std::sorted_equivalent_t,
               std::initializer_list<value_type> init,
               const Allocator& alloc );
(12A) (since C++23)
template< class Allocator >
flat_multimap( std::sorted_equivalent_t,
               std::initializer_list<value_type> init,
               const key_compare& comp, const Allocator& alloc );
(12B) (since C++23)

Constructs new container adaptor from a variety of data sources and optionally using user supplied comparison function object comp and/or allocator alloc.

1) The default constructor. Constructs an empty container adaptor.
2) A copy constructor. Constructs c with the copy of the contents of other.c and compare with other.compare.
3) A move constructor. Constructs the container adaptor with the contents of other using move semantics.
4) Constructs an empty container adaptor.
5) First, initializes c.keys with std::move(key_cont), c.values with std::move(mapped_cont), and compare with comp.
Then sorts the underlying range [begin(), end()) with respect to value_comp().
6) Initializes c.keys with std::move(key_cont), c.values with std::move(mapped_cont), and compare with comp.
If key_cont is not sorted with respect to key_comp(), the behavior is undefined.
7,8) Constructs the container adaptor with the contents of the range [first, last).
If [first, last) is not a valid range, the behavior is undefined.
7) Equivalent to evaluating insert(first, last) after constructing an empty container adaptor.
8) Equivalent to evaluating insert(std::sorted_equivalent, first, last) after constructing an empty container adaptor.
If [first, last) is not sorted with respect to value_comp(), the behavior is undefined.
9,10) Constructs the container adaptor with the contents of the range rg.
Equivalent to evaluating insert_range(std::forward<R>(rg)) after constructing an empty container adaptor.
11,12) Constructs the container adaptor with the contents of the initializer list init.
12) If init is not sorted with respect to value_comp(), the behavior is undefined.

Constructors with allocators are equivalent to the corresponding non-allocator constructors except that the underlying containers c.keys and c.values are constructed with uses-allocator construction. These overloads participate in overload resolution only if both std::uses_allocator_v<key_container_type, Allocator> and std::uses_allocator_v<mapped_container_type, Allocator> are true.

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 - the pair of iterators defining the source range of elements to copy
init - an initializer list to initialize the elements of the underlying containers with
rg - a container compatible range
Type requirements
-
InputIt must meet the requirements of LegacyInputIterator.
-
Compare must meet the requirements of Compare.
-
Allocator must meet the requirements of Allocator.

Complexity

Unless otherwise specified, the complexity requirements on constructors with allocators are the same of those on the corresponding non-allocator constructors.

1) Constant.
2) 𝓞(N), where N is other.size().
3,4) Constant.
5) 𝓞(N) if key_cont and mapped_cont are both sorted with respect to value_comp(), otherwise 𝓞(N·log(N)), where N is the value of key_cont.size() before this call.
6) Constant.
6A,6B) 𝓞(N), where N is the value of key_cont.size() before this call.
7) 𝓞(N) if [first, last) is sorted with respect to value_comp(), otherwise 𝓞(N·log(N)), where N is std::distance(first, last).
8) 𝓞(N), where N is std::distance(first, last).
9) 𝓞(N) if rg is sorted with respect to value_comp(), otherwise 𝓞(N·log(N)), where N is ranges::distance(rg).
10) 𝓞(N), where N is ranges::distance(rg).
11) 𝓞(N) if init is sorted with respect to value_comp(), otherwise 𝓞(N·log(N)), where N is init.size().
12) 𝓞(N), where N is init.size().

Exceptions

Calls to Allocator::allocate may throw.

Notes

After container move construction (overload (3,3A)), references, pointers, and iterators that originally refer to elements in 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.

Example

Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

DR Applied to Behavior as published Correct behavior
P3567R2 C++23 the copy and move constructors were implicit and wrong declared, with correct semantics

See also

assigns values to the container adaptor
(public member function) [edit]