std::flat_set<Key,Compare,KeyContainer>::flat_set
flat_set()
: flat_set(key_compare()) {}
|
(1) | (since C++23) |
flat_set( const flat_set& other );
|
(2) | (since C++23) |
flat_set( flat_set&& other );
|
(3) | (since C++23) |
explicit flat_set( const key_compare& comp )
: c(), compare(comp) {}
|
(4) | (since C++23) |
flat_set( container_type cont,
const key_compare& comp = key_compare() );
|
(5) | (since C++23) |
flat_set( std::sorted_unique_t,
container_type cont,
const key_compare& comp = key_compare() );
|
(6) | (since C++23) |
template< class InputIter >
flat_set( InputIter first, InputIter last,
const key_compare& comp = key_compare() )
: c(), compare(comp);
|
(7) | (since C++23) |
template< class InputIter >
flat_set( std::sorted_unique_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_set( std::from_range_t, R&& rg )
: flat_set(std::from_range, std::forward<R>(rg), key_compare()) {}
|
(9) | (since C++23) |
template< container-compatible-range<value_type> R >
flat_set( std::from_range_t, R&& rg, const key_compare& comp )
: flat_set(comp);
|
(10) | (since C++23) |
flat_set( std::initializer_list<value_type> init,
const key_compare& comp = key_compare() )
: flat_set(init.begin(), init.end(), comp) {}
|
(11) | (since C++23) |
flat_set( std::sorted_unique_t,
std::initializer_list<value_type> init,
const key_compare& comp = key_compare() )
: flat_set(std::sorted_unique,
init.begin(), init.end(), comp) {}
|
(12) | (since C++23) |
| Constructors with allocators |
||
template< class Allocator >
explicit flat_set( const Allocator& alloc );
|
(1A) | (since C++23) |
template< class Allocator >
flat_set( const flat_set& other, const Allocator& alloc );
|
(2A) | (since C++23) |
template< class Allocator >
flat_set( flat_set&& other, const Allocator& alloc );
|
(3A) | (since C++23) |
template< class Allocator >
flat_set( const key_compare& comp, const Allocator& alloc );
|
(4A) | (since C++23) |
template< class Allocator >
flat_set( const container_type& cont,
const Allocator& alloc );
|
(5A) | (since C++23) |
template< class Allocator >
flat_set( const container_type& cont,
const key_compare& comp, const Allocator& alloc );
|
(5B) | (since C++23) |
template< class Allocator >
flat_set( std::sorted_unique_t,
const container_type& cont,
const Allocator& alloc );
|
(6A) | (since C++23) |
template< class Allocator >
flat_set( std::sorted_unique_t,
const container_type& cont,
const key_compare& comp, const Allocator& alloc );
|
(6B) | (since C++23) |
template< class InputIter, class Allocator >
flat_set( InputIter first, InputIter last, const Allocator& alloc );
|
(7A) | (since C++23) |
template< class InputIter, class Allocator >
flat_set( InputIter first, InputIter last,
const key_compare& comp, const Allocator& alloc );
|
(7B) | (since C++23) |
template< class InputIter, class Allocator >
flat_set( std::sorted_unique_t, InputIter first, InputIter last,
const Allocator& alloc );
|
(8A) | (since C++23) |
template< class InputIter, class Allocator >
flat_set( std::sorted_unique_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_set( std::from_range_t, R&& rg, const Allocator& alloc );
|
(9A) | (since C++23) |
template< container-compatible-range<value_type> R, class Allocator >
flat_set( std::from_range_t, R&& rg, const key_compare& comp,
const Allocator& alloc );
|
(10A) | (since C++23) |
template< class Allocator >
flat_set( std::initializer_list<value_type> init,
const Allocator& alloc );
|
(11A) | (since C++23) |
template< class Allocator >
flat_set( std::initializer_list<value_type> init,
const key_compare& comp, const Allocator& alloc );
|
(11B) | (since C++23) |
template< class Allocator >
flat_set( std::sorted_unique_t,
std::initializer_list<value_type> init,
const Allocator& alloc );
|
(12A) | (since C++23) |
template< class Allocator >
flat_set( std::sorted_unique_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.
c with the copy of the contents of other.c and compare with other.compare.other using move semantics.[begin(), end()) with respect to compare .cont is not sorted with respect to key_comp() or contains equal elements, the behavior is undefined.[first, last).[first, last) is not a valid range, the behavior is undefined.insert(first, last) after constructing an empty container adaptor.insert(std::sorted_unique, first, last) after constructing an empty container adaptor.[first, last) is not sorted with respect to key_comp() or contains equal elements, the behavior is undefined.rg.insert_range(std::forward<R>(rg)) after constructing an empty container adaptor.init.init is not sorted with respect to key_comp() or contains equal elements, the behavior is undefined.Constructors with allocators are equivalent to the corresponding non-allocator constructors except that c is constructed with uses-allocator construction. These overloads participate in overload resolution only if std::uses_allocator_v<container_type, Allocator> is true.
Parameters
| cont | - | a container to be used as source to initialize the underlying container |
| other | - | another flat_set to 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 | - | the pair of iterators defining the source range of elements to copy |
| init | - | an initializer list to initialize the elements of the underlying container 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.
other.size().cont is sorted with respect to compare , otherwise 𝓞(N·log(N)), where N is the value of cont.size() before this call.cont.size() before this call.[first, last) is sorted with respect to value_comp(), otherwise 𝓞(N·log(N)), where N is std::distance(first, last).std::distance(first, last).rg is sorted with respect to value_comp(), otherwise 𝓞(N·log(N)), where N is ranges::distance(rg).ranges::distance(rg).init is sorted with respect to value_comp(), otherwise 𝓞(N·log(N)), where N is init.size().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.
If multiple elements in the range have keys that compare equivalent, it is unspecified which element is inserted (pending LWG2844).
Example
| This section is incomplete Reason: no 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 missing | added |
See also
| assigns values to the container adaptor (public member function) |