diff --git a/doc/unordered/unordered_map.adoc b/doc/unordered/unordered_map.adoc index 7c61cfae..e8737402 100644 --- a/doc/unordered/unordered_map.adoc +++ b/doc/unordered/unordered_map.adoc @@ -7,276 +7,197 @@ === Synopsis -[source,c++,subs=+quotes] +[listing,subs="+macros,+quotes"] ----- // #include -template< - typename Key, - typename Mapped, - typename Hash = boost::hash, - typename Pred = std::equal_to, - typename Alloc = std::allocator> > -class unordered_map { -public: - // types - typedef Key key_type; - typedef std::pair value_type; - typedef Mapped mapped_type; - typedef Hash hasher; - typedef Pred key_equal; - typedef Alloc allocator_type; - typedef typename allocator_type::pointer pointer; - typedef typename allocator_type::const_pointer const_pointer; - typedef value_type& reference; - typedef value_type const& const_reference; - typedef _implementation-defined_ size_type; - typedef _implementation-defined_ difference_type; - typedef _implementation-defined_ iterator; - typedef _implementation-defined_ const_iterator; - typedef _implementation-defined_ local_iterator; - typedef _implementation-defined_ const_local_iterator; - typedef _implementation-defined_ node_type; - typedef _implementation-defined_ insert_return_type; +namespace boost { + template, + class Pred = std::equal_to, + class Allocator = std::allocator>> + class unordered_map { + public: + // types + using key_type = Key; + using mapped_type = T; + using value_type = std::pair; + using hasher = Hash; + using key_equal = Pred; + using allocator_type = Allocator; + using pointer = typename boost::allocator_traits::pointer; + using const_pointer = typename boost::allocator_traits::const_pointer; + using reference = value_type&; + using const_reference = const value_type&; + using size_type = _implementation-defined_; + using difference_type = _implementation-defined_; - // construct/copy/destruct - unordered_map(); + using iterator = _implementation-defined_; + using const_iterator = _implementation-defined_; + using local_iterator = _implementation-defined_; + using const_local_iterator = _implementation-defined_; + using node_type = _implementation-defined_; + using insert_return_type = _implementation-defined_; - explicit unordered_map(size_type n, - hasher const& hf = hasher(), - key_equal const& eq = key_equal(), - allocator_type const& a = allocator_type()); + // construct/copy/destroy + xref:#unordered_map_default_constructor[unordered_map](); + explicit xref:#unordered_map_bucket_count_constructor[unordered_map](size_type n, + const hasher& hf = hasher(), + const key_equal& eql = key_equal(), + const allocator_type& a = allocator_type()); + template + xref:#unordered_map_iterator_range_constructor[unordered_map](InputIterator f, InputIterator l, + size_type n = _implementation-defined_, + const hasher& hf = hasher(), + const key_equal& eql = key_equal(), + const allocator_type& a = allocator_type()); + xref:#unordered_map_copy_constructor[unordered_map](const unordered_map& other); + xref:#unordered_map_move_constructor[unordered_map](unordered_map&& other); + explicit xref:#unordered_map_allocator_constructor[unordered_map](const Allocator& a); + xref:#unordered_map_copy_constructor_with_allocator[unordered_map](const unordered_map& other, const Allocator& a); + xref:#unordered_map_move_constructor_with_allocator[unordered_map](unordered_map&& other, const Allocator& a); + xref:#unordered_map_initializer_list_constructor[unordered_map](initializer_list il, + size_type n = _implementation-defined_ + const hasher& hf = hasher(), + const key_equal& eql = key_equal(), + const allocator_type& a = allocator_type()); + xref:#unordered_map_bucket_count_constructor_with_allocator[unordered_map](size_type n, const allocator_type& a); + xref:#unordered_map_bucket_count_constructor_with_hasher_and_allocator[unordered_map](size_type n, const hasher& hf, const allocator_type& a); + template + xref:#unordered_map_iterator_range_constructor_with_bucket_count_and_allocator[unordered_map](InputIterator f, InputIterator l, size_type n, const allocator_type& a); + template + xref:#unordered_map_iterator_range_constructor_with_bucket_count_and_hasher[unordered_map](InputIterator f, InputIterator l, size_type n, const hasher& hf, + const allocator_type& a); + xref:#unordered_map_destructor[~unordered_map](); + unordered_map& xref:#unordered_map_copy_assignment[operator++=++](const unordered_map& other); + unordered_map& xref:#unordered_map_move_assignment[operator++=++](unordered_map&& other) + noexcept(boost::allocator_traits::is_always_equal::value && + boost::is_nothrow_move_assignable_v && + boost::is_nothrow_move_assignable_v); + unordered_map& xref:#unordered_map_initializer_list_assignment[operator++=++](initializer_list); + allocator_type xref:#unordered_map_get_allocator[get_allocator]() const noexcept; - unordered_map(unordered_map const& other); - unordered_map(unordered_map&& other); + // iterators + iterator xref:#unordered_map_begin[begin]() noexcept; + const_iterator xref:#unordered_map_begin[begin]() const noexcept; + iterator xref:#unordered_map_end[end]() noexcept; + const_iterator xref:#unordered_map_end[end]() const noexcept; + const_iterator xref:#unordered_map_cbegin[cbegin]() const noexcept; + const_iterator xref:#unordered_map_cend[cend]() const noexcept; - explicit unordered_map(Allocator const& a); - unordered_map(unordered_map const& other, Allocator const& a); - unordered_map(unordered_map&& other, Allocator const& a); + // capacity + bool xref:#unordered_map_empty[empty]() const noexcept; + size_type xref:#unordered_map_size[size]() const noexcept; + size_type xref:#unordered_map_max_size[max_size]() const noexcept; - unordered_map(size_type n, allocator_type const& a); - unordered_map(size_type n, hasher const& hf, allocator_type const& a); + // modifiers + template std::pair xref:#unordered_map_emplace[emplace](Args&&... args); + template iterator xref:#unordered_map_emplace_hint[emplace_hint](const_iterator position, Args&&... args); + std::pair xref:#unordered_map_copy_insert[insert](const value_type& obj); + std::pair xref:#unordered_map_move_insert[insert](value_type&& obj); + template std::pair xref:#unordered_map_emplace_insert[insert](P&& obj); + iterator xref:#unordered_map_copy_insert_with_hint[insert](const_iterator hint, const value_type& obj); + iterator xref:#unordered_map_move_insert_with_hint[insert](const_iterator hint, value_type&& obj); + template iterator xref:#unordered_map_emplace_insert_with_hint[insert](const_iterator hint, P&& obj); + template void xref:#unordered_map_insert_iterator_range[insert](InputIterator first, InputIterator last); + void xref:#unordered_map_insert_initializer_list[insert](initializer_list); - unordered_map(initializer_list il, - size_type n = _implementation-defined_, - hasher const& hf = hasher(), - key_equal const& eq = key_equal(), - allocator_type const& a = allocator_type()); + node_type xref:#unordered_map_extract_by_iterator[extract](const_iterator position); + node_type xref:#unordered_map_extract_by_key[extract](const key_type& k); + template node_type xref:#unordered_map_transparent_extract_by_key[extract](K&& k); + insert_return_type xref:#unordered_map_insert_with_node_handle[insert](node_type&& nh); + iterator xref:#unordered_map_insert_with_hint_and_node_handle[insert](const_iterator hint, node_type&& nh); - template - unordered_map(InputIterator f, - InputIterator l, - size_type n = _implementation-defined_, - hasher const& hf = hasher(), - key_equal const& eq = key_equal(), - allocator_type const& a = allocator_type()); + iterator xref:#unordered_map_erase_by_position[erase](iterator position); + iterator xref:#unordered_map_erase_by_position[erase](const_iterator position); + size_type xref:#unordered_map_erase_by_key[erase](const key_type& k); + template size_type xref:#unordered_map_transparent_erase_by_key[erase](K&& k); + iterator xref:#unordered_map_erase_range[erase](const_iterator first, const_iterator last); + void xref:#unordered_map_quick_erase[quick_erase](const_iterator position); + void xref:#unordered_map_erase_return_void[erase_return_void](const_iterator position); + void xref:#unordered_map_swap[swap](unordered_map& other) + noexcept(boost::allocator_traits::is_always_equal::value && + boost::is_nothrow_swappable_v && + boost::is_nothrow_swappable_v); + void xref:#unordered_map_clear[clear]() noexcept; - template - unordered_map(InputIterator f, - InputIterator l, - size_type n, - allocator_type const& a); + template + void xref:#unordered_map_merge[merge](unordered_map& source); + template + void xref:#unordered_map_merge_rvalue_reference[merge](unordered_map&& source); - template - unordered_map(InputIterator f, - InputIterator l, - size_type n, - hasher const& hf, - allocator_type const& a); + // observers + hasher xref:#unordered_map_hash_function[hash_function]() const; + key_equal xref:#unordered_map_key_eq[key_eq]() const; - ~unordered_map(); + // map operations + iterator xref:#unordered_map_find[find](const key_type& k); + const_iterator xref:#unordered_map_find[find](const key_type& k) const; + template + iterator xref:#unordered_map_find[find](const K& k); + template + const_iterator xref:#unordered_map_find[find](const K& k) const; + template + iterator xref:#unordered_map_find[find](CompatibleKey const& k, CompatibleHash const& hash, + CompatiblePredicate const& eq); + template + const_iterator xref:#unordered_map_find[find](CompatibleKey const& k, CompatibleHash const& hash, + CompatiblePredicate const& eq) const; + size_type xref:#unordered_map_count[count](const key_type& k) const; + template + size_type xref:#unordered_map_count[count](const K& k) const; + bool xref:#unordered_map_contains[contains](const key_type& k) const; + template + bool xref:#unordered_map_contains[contains](const K& k) const; + pair xref:#unordered_map_equal_range[equal_range](const key_type& k); + pair xref:#unordered_map_equal_range[equal_range](const key_type& k) const; + template + pair xref:#unordered_map_equal_range[equal_range](const K& k); + template + pair xref:#unordered_map_equal_range[equal_range](const K& k) const; - unordered_map& operator=(unordered_map const& other); - unordered_map& operator=(unordered_map&& other); - unordered_map& operator=(initializer_list il); + // element access + mapped_type& xref:#unordered_map_operator[operator[+]+](const key_type& k); + mapped_type& xref:#unordered_map_operator[operator[+]+](key_type&& k); + mapped_type& xref:#unordered_map_at[at](const key_type& k); + const mapped_type& xref:#unordered_map_at[at](const key_type& k) const; - // size and capacity - bool empty() const; - size_type size() const; - size_type max_size() const; + // bucket interface + size_type xref:#unordered_map_bucket_count[bucket_count]() const noexcept; + size_type xref:#unordered_map_max_bucket_count[max_bucket_count]() const noexcept; + size_type xref:#unordered_map_bucket_size[bucket_size](size_type n) const; + size_type xref:#unordered_map_bucket[bucket](const key_type& k) const; + local_iterator xref:#unordered_map_begin_2[begin](size_type n); + const_local_iterator xref:#unordered_map_begin_2[begin](size_type n) const; + local_iterator xref:#unordered_map_end_2[end](size_type n); + const_local_iterator xref:#unordered_map_end_2[end](size_type n) const; + const_local_iterator xref:#unordered_map_cbegin_2[cbegin](size_type n) const; + const_local_iterator xref:#unordered_map_cend_2[cend](size_type n) const; - // iterators - iterator begin(); - const_iterator begin() const; - - iterator end(); - const_iterator end() const; - - const_iterator cbegin() const; - const_iterator cend() const; - - // modifiers - template - std::pair - emplace(Args&&... args); - - template - iterator - emplace_hint(const_iterator hint, Args&&... args); - - std::pair - insert(value_type const& obj); - - std::pair - insert(value_type&& obj); - - template - std::pair - insert(P&& value); - - insert_return_type insert(node_type&& nh); - - iterator insert(const_iterator hint, value_type const& obj); - iterator insert(const_iterator hint, value_type&& obj); - iterator insert(const_iterator hint, node_type&& nh); - - template - iterator - insert(const_iterator hint, P&& value); - - template - void insert(InputIterator first, InputIterator last); - - void insert(initializer_list il); - - node_type extract(const_iterator position); - node_type extract(key_type const& k); - - template - node_type extract(K&& k); - - iterator erase(const_iterator position); - iterator erase(const_iterator first, const_iterator last); - size_type erase(key_type const& k); - - template - size_type erase(K&& k); - - void quick_erase(const_iterator position); - void erase_return_void(const_iterator position); - - void clear(); - void swap(unordered_map& other); - - template - void merge(unordered_map& source); - - template - void merge(unordered_map&& source); - - // observers - allocator_type get_allocator() const; - hasher hash_function() const; - key_equal key_eq() const; - - // lookup - iterator find(key_type const& k); - const_iterator find(key_type const& k) const; - - template - iterator - find(K const& k); - - template - const_iterator - find(K const& k) const; - - template< - typename CompatibleKey, - typename CompatibleHash, - typename CompatiblePredicate> - iterator - find(CompatibleKey const& k, - CompatibleHash const& hash, - CompatiblePredicate const&) eq; - - template< - typename CompatibleKey, - typename CompatibleHash, - typename CompatiblePredicate> - const_iterator - find(CompatibleKey const& k, - CompatibleHash const& hash, - CompatiblePredicate const& eq) const; - - bool contains(key_type const& key) const; - - template - bool contains(K const& key); - - size_type count(key_type const& k) const; - - template - size_type count(K const& k) const; - - std::pair - equal_range(key_type const& k); - - std::pair - equal_range(key_type const& k) const; - - template - std::pair - equal_range(K const& k); - - template - std::pair - equal_range(K const& k) const; - - mapped_type& operator[](key_type const& k); - - Mapped& at(key_type const& k); - Mapped const& at(key_type const& k) const; - - // bucket interface - size_type bucket_count() const; - size_type max_bucket_count() const; - size_type bucket_size(size_type n) const; - size_type bucket(key_type const& k) const; - - local_iterator begin(size_type n); - const_local_iterator begin(size_type n) const; - - local_iterator end(size_type n); - const_local_iterator end(size_type n) const; - - const_local_iterator cbegin(size_type n) const; - const_local_iterator cend(size_type n) const; - - // hash policy - float load_factor() const; - float max_load_factor() const; - - void max_load_factor(float z); - - void rehash(size_type n); - void reserve(size_type n); -}; + // hash policy + float xref:#unordered_map_load_factor[load_factor]() const noexcept; + float xref:#unordered_map_max_load_factor[max_load_factor]() const noexcept; + void xref:#unordered_map_set_max_load_factor[max_load_factor](float z); + void xref:#unordered_map_rehash[rehash](size_type n); + void xref:#unordered_map_reserve[reserve](size_type n); + }; +} // Equality Comparisons -template< - typename Key, - typename Mapped, - typename Hash, - typename Pred, - typename Alloc> -bool operator==(unordered_map const& x, - unordered_map const& y); +template + bool xref:#unordered_map_operator_2[operator==](const unordered_map& x, + const unordered_map& y); -template< - typename Key, - typename Mapped, - typename Hash, - typename Pred, - typename Alloc> -bool operator!=(unordered_map const& x, - unordered_map const& y); +template + bool xref:#unordered_map_operator_3[operator!=](const unordered_map& x, + const unordered_map& y); // swap -template -void swap(unordered_map& x, - unordered_map& y); +template + void xref:#unordered_map_swap_2[swap](unordered_map& x, + unordered_map& y) + noexcept(noexcept(x.swap(y))); ----- --- @@ -291,8 +212,8 @@ void swap(unordered_map& x, |_Key_ |`Key` must be https://en.cppreference.com/w/cpp/named_req/Erasable[Erasable^] from the container (i.e. `allocator_traits` can destroy it). -|_Mapped_ -|`Mapped` must be https://en.cppreference.com/w/cpp/named_req/Erasable[Erasable^] from the container (i.e. `allocator_traits` can destroy it). +|_T_ +|`T` must be https://en.cppreference.com/w/cpp/named_req/Erasable[Erasable^] from the container (i.e. `allocator_traits` can destroy it). |_Hash_ |A unary function object type that acts a hash function for a `Key`. It takes a single argument of type `Key` and returns a value of type `std::size_t`. @@ -300,7 +221,7 @@ void swap(unordered_map& x, |_Pred_ |A binary function object that implements an equivalence relation on values of type `Key`. A binary function object that induces an equivalence relation on values of type `Key`. It takes two arguments of type `Key` and returns a value of type bool. -|_Alloc_ +|_Allocator_ |An allocator whose value type is the same as the container's value type. |=== @@ -429,26 +350,45 @@ Constructs an empty container using `hasher()` as the hash function, `key_equal()` as the key equality predicate, `allocator_type()` as the allocator and a maximum load factor of `1.0`. -Postconditions:: `size() == 0` -Requires:: If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. +[horizontal] +Postconditions:;; `size() == 0` +Requires:;; If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. --- ==== Bucket Count Constructor ```c++ explicit unordered_map(size_type n, - hasher const& hf = hasher(), - key_equal const& eq = key_equal(), - allocator_type const& a = allocator_type()); + const hasher& hf = hasher(), + const key_equal& eql = key_equal(), + const allocator_type& a = allocator_type()); ``` Constructs an empty container with at least `n` buckets, using `hf` as the hash -function, `eq` as the key equality predicate, `a` as the allocator and a maximum +function, `eql` as the key equality predicate, `a` as the allocator and a maximum load factor of `1.0`. -Postconditions:: `size() == 0` +[horizontal] +Postconditions:;; `size() == 0` +Requires:;; If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. -Requires:: If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. +--- + +==== Iterator Range Constructor +[source,c++,subs="+quotes"] +---- +template + unordered_map(InputIterator f, InputIterator l, + size_type n = _implementation-defined_, + const hasher& hf = hasher(), + const key_equal& eql = key_equal(), + const allocator_type& a = allocator_type()); +---- + +Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `eql` as the key equality predicate, `a` as the allocator and a maximum load factor of `1.0` and inserts the elements from `[f, l)` into it. + +[horizontal] +Requires:;; If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. --- @@ -461,7 +401,8 @@ The copy constructor. Copies the contained elements, hash function, predicate, m If `Allocator::select_on_container_copy_construction` exists and has the right signature, the allocator will be constructed from its result. -Requires:: `value_type` is copy constructible +[horizontal] +Requires:;; `value_type` is copy constructible --- @@ -472,9 +413,11 @@ unordered_map(unordered_map&& other); The move constructor. -Notes:: This is implemented using Boost.Move. - -Requires:: `value_type` is move-constructible. On compilers without rvalue reference support the emulation does not support moving without calling `boost::move` if `value_type` is not copyable. +[horizontal] +Notes:;; This is implemented using Boost.Move. +Requires:;; `value_type` is move-constructible. + ++ +On compilers without rvalue reference support the emulation does not support moving without calling `boost::move` if `value_type` is not copyable. So, for example, you can't return the container from a function. --- @@ -504,8 +447,26 @@ unordered_map(unordered_map&& other, Allocator const& a); Construct a container moving ``other``'s contained elements, and having the hash function, predicate and maximum load factor, but using allocate `a`. -Notes:: This is implemented using Boost.Move. -Requires:: `value_type` is move insertable. +[horizontal] +Notes:;; This is implemented using Boost.Move. +Requires:;; `value_type` is move insertable. + +--- + +==== Initializer List Constructor +[source,c++,subs="+quotes"] +---- +unordered_map(initializer_list il, + size_type n = _implementation-defined_ + const hasher& hf = hasher(), + const key_equal& eql = key_equal(), + const allocator_type& a = allocator_type()); +---- + +Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `eql` as the key equality predicate, `a` as the allocator and a maximum load factor of `1.0` and inserts the elements from `il` into it. + +[horizontal] +Requires:;; If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. --- @@ -516,8 +477,9 @@ unordered_map(size_type n, allocator_type const& a); Constructs an empty container with at least `n` buckets, using `hf` as the hash function, the default hash function and key equality predicate, `a` as the allocator and a maximum load factor of `1.0`. -Postconditions:: `size() == 0` -Requires:: `hasher` and `key_equal` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. +[horizontal] +Postconditions:;; `size() == 0` +Requires:;; `hasher` and `key_equal` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. --- @@ -528,73 +490,38 @@ unordered_map(size_type n, hasher const& hf, allocator_type const& a); Constructs an empty container with at least `n` buckets, using `hf` as the hash function, the default key equality predicate, `a` as the allocator and a maximum load factor of `1.0`. -Postconditions:: `size() == 0` -Requires:: `key_equal` needs to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. - ---- - -==== Initializer List Constructor -[source,c++,subs="quotes,macros"] ----- -unordered_map(initializer_list++<++value_type++>++ il, - size_type n = _implementation-defined_, - hasher const& hf = hasher(), - key_equal const& eq = key_equal(), - allocator_type const& a = allocator_type()); ----- - -Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `eq` as the key equality predicate, `a` as the allocator and a maximum load factor of `1.0` and inserts the elements from `il` into it. - -Requires:: If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. - ---- - -==== Iterator Range Constructor -[source,c++,subs="quotes,macros"] ----- -template++<++typename InputIterator++>++ -unordered_map(InputIterator f, - InputIterator l, - size_type n = _implementation-defined_, - hasher const& hf = hasher(), - key_equal const& eq = key_equal(), - allocator_type const& a = allocator_type()); ----- - -Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `eq` as the key equality predicate, `a` as the allocator and a maximum load factor of `1.0` and inserts the elements from `[f, l)` into it. - -Requires:: If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. +[horizontal] +Postconditions:;; `size() == 0` +Requires:;; `key_equal` needs to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. --- ==== Iterator Range Constructor with Bucket Count and Allocator -[source,c++,subs="quotes,macros"] +[source,c++,subs="+quotes"] ---- -template++<++typename InputIterator++>++ -unordered_map(InputIterator f, - InputIterator l, - size_type n, - allocator_type const& a); +template + unordered_map(InputIterator f, InputIterator l, size_type n, const allocator_type& a); ---- Constructs an empty container with at least `n` buckets, using `a` as the allocator, with the default hash function and key equality predicate and a maximum load factor of `1.0` and inserts the elements from `[f, l)` into it. -Requires:: `hasher`, `key_equal` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. +[horizontal] +Requires:;; `hasher`, `key_equal` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. + +--- ==== Iterator Range Constructor with Bucket Count and Hasher -[source,c++,subs="quotes,macros"] +[source,c++,subs="+quotes"] ---- -template++<++typename InputIterator++>++ -unordered_map(InputIterator f, - InputIterator l, - size_type n, - hasher const& hf, - allocator_type const& a); + template + unordered_map(InputIterator f, InputIterator l, size_type n, const hasher& hf, + const allocator_type& a); ---- Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `a` as the allocator, with the default key equality predicate and a maximum load factor of `1.0` and inserts the elements from `[f, l)` into it. -Requires:: `key_equal` needs to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. +[horizontal] +Requires:;; `key_equal` needs to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. --- @@ -603,7 +530,9 @@ Requires:: `key_equal` needs to be https://en.cppreference.com/w/cpp/named_req/D ```c++ ~unordered_map(); ``` -Note:: The destructor is applied to every element, and all memory is deallocated + +[horizontal] +Note:;; The destructor is applied to every element, and all memory is deallocated --- @@ -619,21 +548,25 @@ The assignment operator. Copies the contained elements, hash function, predicate If `Alloc::propagate_on_container_copy_assignment` exists and `Alloc::propagate_on_container_copy_assignment::value` is `true`, the allocator is overwritten, if not the copied elements are created using the existing allocator. -Requires:: `value_type` is copy constructible +[horizontal] +Requires:;; `value_type` is copy constructible --- ==== Move Assignment ```c++ -unordered_map& operator=(unordered_map&& other); +unordered_map& operator=(unordered_map&& other) + noexcept(boost::allocator_traits::is_always_equal::value && + boost::is_nothrow_move_assignable_v && + boost::is_nothrow_move_assignable_v); ``` The move assignment operator. If `Alloc::propagate_on_container_move_assignment` exists and `Alloc::propagate_on_container_move_assignment::value` is `true`, the allocator is overwritten, if not the moved elements are created using the existing allocator. -Notes:: On compilers without rvalue references, this is emulated using Boost.Move. Note that on some compilers the copy assignment operator may be used in some circumstances. - -Requires:: `value_type` is move constructible. +[horizontal] +Notes:;; On compilers without rvalue references, this is emulated using Boost.Move. Note that on some compilers the copy assignment operator may be used in some circumstances. +Requires:;; `value_type` is move constructible. --- @@ -644,76 +577,85 @@ unordered_map& operator=(initializer_list il); Assign from values in initializer list. All existing elements are either overwritten by the new elements or destroyed. -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^] into the container and https://en.cppreference.com/w/cpp/named_req/CopyAssignable[CopyAssignable^]. +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^] into the container and https://en.cppreference.com/w/cpp/named_req/CopyAssignable[CopyAssignable^]. + +=== Iterators + +==== begin +```c++ +iterator begin() noexcept; +const_iterator begin() const noexcept; +``` + +[horizontal] +Returns:;; An iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container. + +--- + +==== end +```c++ +iterator end() noexcept; +const_iterator end() const noexcept; +``` + +[horizontal] +Returns:;; An iterator which refers to the past-the-end value for the container. + +--- + +==== cbegin +```c++ +const_iterator cbegin() const noexcept; +``` + +[horizontal] +Returns:;; A `const_iterator` referring to the first element of the container, or if the container is empty the past-the-end value for the container. + +--- + +==== cend +```c++ +const_iterator cend() const noexcept; +``` + +[horizontal] +Returns:;; A `const_iterator` which refers to the past-the-end value for the container. + +--- === Size and Capacity ==== empty ```c++ -bool empty() const; +bool empty() const noexcept; ``` -Returns:: `size() == 0` +[horizontal] +Returns:;; `size() == 0` --- ==== size ```c++ -size_type size() const; +size_type size() const noexcept; ``` -Returns:: `std::distance(begin(), end())` +[horizontal] +Returns:;; `std::distance(begin(), end())` --- ==== max_size ```c++ -size_type max_size() const; +size_type max_size() const noexcept; ``` -Returns:: `size()` of the largest possible container. - ---- - -=== Iterators - -==== begin -```c++ -iterator begin(); -const_iterator begin() const; -``` - -Returns:: An iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container. - ---- - -==== end -```c++ -iterator end(); -const_iterator end() const; -``` - -Returns:: An iterator which refers to the past-the-end value for the container. - ---- - -==== cbegin -```c++ -const_iterator cbegin() const; -``` -Returns:: A `const_iterator` referring to the first element of the container, or if the container is empty the past-the-end value for the container. - ---- - -==== cend -```c++ -const_iterator cend() const; -``` - -Returns:: A `const_iterator` which refers to the past-the-end value for the container. +[horizontal] +Returns:;; `size()` of the largest possible container. --- @@ -721,138 +663,123 @@ Returns:: A `const_iterator` which refers to the past-the-end value for the cont ==== emplace ```c++ -template -std::pair -emplace(Args&&... args); +template std::pair emplace(Args&&... args); ``` Inserts an object, constructed with the arguments `args`, in the container if and only if there is no element in the container with an equivalent key. -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `args`. - -Returns:: The bool component of the return type is true if an insert took place. + +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `args`. +Returns:;; The bool component of the return type is true if an insert took place. + ++ If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. - -Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. -Pointers and references to elements are never invalidated. -If the compiler doesn't support variadic template arguments or rvalue references, this is emulated for up to `10` arguments, with no support for rvalue references or move semantics. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. + ++ +If the compiler doesn't support variadic template arguments or rvalue references, this is emulated for up to `10` arguments, with no support for rvalue references or move semantics. + ++ Since existing `std::pair` implementations don't support `std::piecewise_construct` this emulates it, but using `boost::unordered::piecewise_construct`. --- ==== emplace_hint ```c++ -template -iterator -emplace_hint(const_iterator hint, Args&&... args); + template iterator emplace_hint(const_iterator position, Args&&... args); ``` Inserts an object, constructed with the arguments `args`, in the container if and only if there is no element in the container with an equivalent key. -`hint` is a suggestion to where the element should be inserted. +`position` is a suggestion to where the element should be inserted. -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `args`. - -Returns:: If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. - -Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. -Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. -Pointers and references to elements are never invalidated. -If the compiler doesn't support variadic template arguments or rvalue references, this is emulated for up to 10 arguments, with no support for rvalue references or move semantics. +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `args`. +Returns:;; If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. + ++ +Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. + ++ +If the compiler doesn't support variadic template arguments or rvalue references, this is emulated for up to 10 arguments, with no support for rvalue references or move semantics. + ++ Since existing `std::pair` implementations don't support `std::piecewise_construct` this emulates it, but using `boost::unordered::piecewise_construct`. --- ==== Copy Insert ```c++ -std::pair -insert(value_type const& obj); +std::pair insert(const value_type& obj); ``` Inserts `obj` in the container if and only if there is no element in the container with an equivalent key. -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^]. - -Returns:: The bool component of the return type is true if an insert took place. If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. - -Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^]. +Returns:;; The bool component of the return type is true if an insert took place. + ++ +If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. --- ==== Move Insert ```c++ -std::pair -insert(value_type&& obj); +std::pair insert(value_type&& obj); ``` Inserts `obj` in the container if and only if there is no element in the container with an equivalent key. -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/MoveInsertable[MoveInsertable^]. - -Returns:: The bool component of the return type is true if an insert took place. If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. - -Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/MoveInsertable[MoveInsertable^]. +Returns:;; The bool component of the return type is true if an insert took place. + ++ +If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. --- ==== Emplace Insert ```c++ -template -std::pair -insert(P&& value); +template std::pair insert(P&& obj); ``` Inserts an element into the container by performing `emplace(std::forward

(value))`. Only participates in overload resolution if `std::is_constructible::value` is `true`. -Returns:: The bool component of the return type is true if an insert took place. If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. - ---- - -==== Insert with `node_handle` -```c++ -insert_return_type -insert(node_type&& nh); -``` - -If `nh` is empty, has no effect. - -Otherwise inserts the element owned by `nh` if and only if there is no element in the container with an equivalent key. - -Requires:: `nh` is empty or `nh.get_allocator()` is equal to the container's allocator. - -Returns:: If `nh` was empty, returns an `insert_return_type` with: `inserted` equal to `false`, `position` equal to `end()` and `node` empty. Otherwise if there was already an element with an equivalent key, returns an `insert_return_type` with: `inserted` equal to `false`, `position` pointing to a matching element and `node` contains the node from `nh`. Otherwise if the insertion succeeded, returns an `insert_return_type` with: `inserted` equal to `true`, `position` pointing to the newly inserted element and `node` empty. - -Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. In C++17 this can be used to insert a node extracted from a compatible `unordered_multimap`, but that is not supported yet. +[horizontal] +Returns:;; The bool component of the return type is true if an insert took place. + ++ +If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. --- ==== Copy Insert with Hint ```c++ -iterator insert(const_iterator hint, value_type const& obj); +iterator insert(const_iterator hint, const value_type& obj); ``` Inserts `obj` in the container if and only if there is no element in the container with an equivalent key. `hint` is a suggestion to where the element should be inserted. -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^]. - -Returns:: If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. - -Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^]. +Returns:;; If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. + ++ +Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. --- @@ -865,22 +792,22 @@ Inserts `obj` in the container if and only if there is no element in the contain `hint` is a suggestion to where the element should be inserted. -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/MoveInsertable[MoveInsertable^]. - -Returns:: If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. - -Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/MoveInsertable[MoveInsertable^]. +Returns:;; If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. + ++ +Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. --- ==== Emplace Insert with Hint ```c++ -template -std::pair -insert(const_iterator hint, P&& value); +template iterator insert(const_iterator hint, P&& obj); ``` Inserts an element into the container by performing `emplace_hint(hint, std::forward

(value))`. @@ -889,9 +816,113 @@ Only participates in overload resolution if `std::is_constructible void insert(InputIterator first, InputIterator last); +``` + +Inserts a range of elements into the container. Elements are inserted if and only if there is no element in the container with an equivalent key. + +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `*first`. +Throws:;; When inserting a single element, if an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. + +--- + +==== Insert Initializer List +```c++ +void insert(initializer_list); +``` + +Inserts a range of elements into the container. Elements are inserted if and only if there is no element in the container with an equivalent key. + +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `*first`. +Throws:;; When inserting a single element, if an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. + +--- + +==== Extract by Iterator +```c++ +node_type extract(const_iterator position); +``` + +Removes the element pointed to by `position`. + +[horizontal] +Returns:;; A `node_type` owning the element. +Notes:;; In C++17 a node extracted using this method can be inserted into a compatible `unordered_multimap`, but that is not supported yet. + +--- + +==== Extract by Key +```c++ +node_type extract(const key_type& k); +``` + +Removes an element with key equivalent to `k`. + +[horizontal] +Returns:;; A `node_type` owning the element if found, otherwise an empty `node_type`. +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. +Notes:;; In C++17 a node extracted using this method can be inserted into a compatible `unordered_multimap`, but that is not supported yet. + +--- + +==== Transparent Extract by Key +```c++ +template node_type extract(K&& k); +``` + +Removes an element with key equivalent to `k`. + +This overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs and neither `iterator` nor `const_iterator` are implicitly convertible from `K`. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. + +[horizontal] +Returns:;; A `node_type` owning the element if found, otherwise an empty `node_type`. +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. +Notes:;; In C++17 a node extracted using this method can be inserted into a compatible `unordered_multimap`, but that is not supported yet. + +--- + +==== Insert with `node_handle` +```c++ +insert_return_type insert(node_type&& nh); +``` + +If `nh` is empty, has no effect. + +Otherwise inserts the element owned by `nh` if and only if there is no element in the container with an equivalent key. + +[horizontal] +Requires:;; `nh` is empty or `nh.get_allocator()` is equal to the container's allocator. +Returns:;; If `nh` was empty, returns an `insert_return_type` with: `inserted` equal to `false`, `position` equal to `end()` and `node` empty. + ++ +Otherwise if there was already an element with an equivalent key, returns an `insert_return_type` with: `inserted` equal to `false`, `position` pointing to a matching element and `node` contains the node from `nh`. + ++ +Otherwise if the insertion succeeded, returns an `insert_return_type` with: `inserted` equal to `true`, `position` pointing to the newly inserted element and `node` empty. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. + ++ +In C++17 this can be used to insert a node extracted from a compatible `unordered_multimap`, but that is not supported yet. --- @@ -908,104 +939,65 @@ If there is already an element in the container with an equivalent key has no ef `hint` is a suggestion to where the element should be inserted. -Requires:: `nh` is empty or `nh.get_allocator()` is equal to the container's allocator. - -Returns:: If `nh` was empty returns `end()`. If there was already an element in the container with an equivalent key returns an iterator pointing to that. Otherwise returns an iterator pointing to the newly inserted element. - -Throws:: If an exception is thrown by an operation other than a call to hasher the function has no effect. - -Notes:: The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. In C++17 this can be used to insert a node extracted from a compatible `unordered_multimap`, but that is not supported yet. +[horizontal] +Requires:;; `nh` is empty or `nh.get_allocator()` is equal to the container's allocator. +Returns:;; If `nh` was empty returns `end()`. + ++ +If there was already an element in the container with an equivalent key returns an iterator pointing to that. + ++ +Otherwise returns an iterator pointing to the newly inserted element. +Throws:;; If an exception is thrown by an operation other than a call to hasher the function has no effect. +Notes:;; The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. + ++ +Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. + ++ +In C++17 this can be used to insert a node extracted from a compatible `unordered_multimap`, but that is not supported yet. --- -==== Insert Iterator Range -```c++ -template -void insert(InputIterator first, InputIterator last); -``` - -Inserts a range of elements into the container. Elements are inserted if and only if there is no element in the container with an equivalent key. - -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `*first`. - -Throws:: When inserting a single element, if an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. - ---- - -==== Insert Initializer List -```c++ -void insert(initializer_list il); -``` - -Inserts a range of elements into the container. Elements are inserted if and only if there is no element in the container with an equivalent key. - -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `*first`. - -Throws:: When inserting a single element, if an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. - ---- - -==== Extract by Iterator -```c++ -node_type extract(const_iterator position); -``` - -Removes the element pointed to by `position`. - -Returns:: A `node_type` owning the element. - -Notes:: In C++17 a node extracted using this method can be inserted into a compatible `unordered_multimap`, but that is not supported yet. - ---- - -==== Transparent Extract by Key -```c++ -template -node_type extract(K&& k); -``` - -Removes an element with key equivalent to `k`. - -This overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs and neither `iterator` nor `const_iterator` are implicitly convertible from `K`. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. - -Returns:: A `node_type` owning the element if found, otherwise an empty `node_type`. - -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. - -Notes:: In C++17 a node extracted using this method can be inserted into a compatible `unordered_multimap`, but that is not supported yet. - ---- - -==== Extract by Key -```c++ -node_type extract(key_type const& k); -``` - -Removes an element with key equivalent to `k`. - -Returns:: A `node_type` owning the element if found, otherwise an empty `node_type`. - -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. - -Notes:: In C++17 a node extracted using this method can be inserted into a compatible `unordered_multimap`, but that is not supported yet. - ==== Erase by Position ```c++ +iterator erase(iterator position); iterator erase(const_iterator position); ``` Erase the element pointed to by `position`. -Returns:: The iterator following `position` before the erasure. +[horizontal] +Returns:;; The iterator following `position` before the erasure. +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. +Notes:;; In older versions this could be inefficient because it had to search through several buckets to find the position of the returned iterator. The data structure has been changed so that this is no longer the case, and the alternative erase methods have been deprecated. -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. +--- -Notes:: In older versions this could be inefficient because it had to search through several buckets to find the position of the returned iterator. The data structure has been changed so that this is no longer the case, and the alternative erase methods have been deprecated. +==== Erase by Key +```c++ +size_type erase(const key_type& k); +``` + +Erase all elements with key equivalent to `k`. + +[horizontal] +Returns:;; The number of elements erased. +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. + +--- + +==== Transparent Erase by Key +```c++ +template size_type erase(K&& k); +``` + +Erase all elements with key equivalent to `k`. + +This overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs and neither `iterator` nor `const_iterator` are implicitly convertible from `K`. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. + +[horizontal] +Returns:;; The number of elements erased. +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. --- @@ -1017,38 +1009,11 @@ iterator erase(const_iterator first, const_iterator last); Erases the elements in the range from `first` to `last`. -Returns:: The iterator following the erased elements - i.e. `last`. - -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations. - ---- - -==== Transparent Erase by Key -```c++ -template -size_type erase(K&& k); -``` - -Erase all elements with key equivalent to `k`. - -This overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs and neither `iterator` nor `const_iterator` are implicitly convertible from `K`. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. - -Returns:: The number of elements erased. - -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. - ---- - -==== Erase by Key -```c++ -size_type erase(key_type const& k); -``` - -Erase all elements with key equivalent to `k`. - -Returns:: The number of elements erased. - -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. +[horizontal] +Returns:;; The iterator following the erased elements - i.e. `last`. +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. + ++ +In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations. --- @@ -1059,9 +1024,11 @@ void quick_erase(const_iterator position); Erase the element pointed to by `position`. -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations. - -Notes:: This method was implemented because returning an iterator to the next element from erase was expensive, but the container has been redesigned so that is no longer the case. So this method is now deprecated. +[horizontal] +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. + ++ +In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations. +Notes:;; This method was implemented because returning an iterator to the next element from erase was expensive, but the container has been redesigned so that is no longer the case. So this method is now deprecated. --- @@ -1072,9 +1039,29 @@ void erase_return_void(const_iterator position); Erase the element pointed to by `position`. -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations. +[horizontal] +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. + ++ +In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations. +Notes:;; This method was implemented because returning an iterator to the next element from erase was expensive, but the container has been redesigned so that is no longer the case. So this method is now deprecated. -Notes:: This method was implemented because returning an iterator to the next element from erase was expensive, but the container has been redesigned so that is no longer the case. So this method is now deprecated. +--- + +==== swap +```c++ +void swap(unordered_map& other) + noexcept(boost::allocator_traits::is_always_equal::value && + boost::is_nothrow_swappable_v && + boost::is_nothrow_swappable_v); +``` + +Swaps the contents of the container with the parameter. + +If `Allocator::propagate_on_container_swap` is declared and `Allocator::propagate_on_container_swap::value` is `true` then the containers' allocators are swapped. Otherwise, swapping with unequal allocators results in undefined behavior. + +[horizontal] +Throws:;; Doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of `key_equal` or `hasher`. +Notes:;; The exception specifications aren't quite the same as the C++11 standard, as the equality predicate and hash function are swapped using their copy constructors. --- @@ -1085,44 +1072,31 @@ void clear(); Erases all elements in the container. -Postconditions:: `size() == 0` - -Throws:: Never throws an exception. - ---- - -==== swap -```c++ -void swap(unordered_map& other); -``` - -Swaps the contents of the container with the parameter. - -If `Allocator::propagate_on_container_swap` is declared and `Allocator::propagate_on_container_swap::value` is `true` then the containers' allocators are swapped. Otherwise, swapping with unequal allocators results in undefined behavior. - -Throws:: Doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of `key_equal` or `hasher`. - -Notes:: The exception specifications aren't quite the same as the C++11 standard, as the equality predicate and hash function are swapped using their copy constructors. +[horizontal] +Postconditions:;; `size() == 0` +Throws:;; Never throws an exception. --- ==== merge ```c++ template -void merge(unordered_map& source); +void merge(unordered_map& source); ``` -Notes:: Does not support merging with a compatible `unordered_multimap` yet. +[horizontal] +Notes:;; Does not support merging with a compatible `unordered_multimap` yet. --- ==== merge (rvalue reference) ```c++ template -void merge(unordered_map&& source); +void merge(unordered_map&& source); ``` -Notes:: Does not support merging with a compatible `unordered_multimap` yet. +[horizontal] +Notes:;; Does not support merging with a compatible `unordered_multimap` yet. --- @@ -1133,20 +1107,25 @@ Notes:: Does not support merging with a compatible `unordered_multimap` yet. allocator_type get_allocator() const; ``` +--- + ==== hash_function ``` hasher hash_function() const; ``` -Returns:: The container's hash function. +[horizontal] +Returns:;; The container's hash function. --- +==== key_eq ``` key_equal key_eq() const; ``` -Returns:: The container's key equality predicate +[horizontal] +Returns:;; The container's key equality predicate --- @@ -1154,117 +1133,96 @@ Returns:: The container's key equality predicate ==== find ```c++ -iterator find(key_type const& k); -const_iterator find(key_type const& k) const; - -template -iterator -find(K const& k); - -template -const_iterator -find(K const& k) const; - -template< - typename CompatibleKey, - typename CompatibleHash, - typename CompatiblePredicate> -iterator -find(CompatibleKey const& k, - CompatibleHash const& hash, - CompatiblePredicate const& eq); - -template< - typename CompatibleKey, - typename CompatibleHash, - typename CompatiblePredicate> -const_iterator -find(CompatibleKey const& k, - CompatibleHash const& hash, - CompatiblePredicate const& eq) const; +iterator find(const key_type& k); +const_iterator find(const key_type& k) const; +template + iterator find(const K& k); +template + const_iterator find(const K& k) const; +template + iterator find(CompatibleKey const& k, CompatibleHash const& hash, + CompatiblePredicate const& eq); +template + const_iterator find(CompatibleKey const& k, CompatibleHash const& hash, + CompatiblePredicate const& eq) const; ``` -Returns:: An iterator pointing to an element with key equivalent to `k`, or `b.end()` if no such element exists. - -Notes:: The templated overloads containing `CompatibleKey`, `CompatibleHash` and `CompatiblePredicate` are non-standard extensions which allow you to use a compatible hash function and equality predicate for a key of a different type in order to avoid an expensive type cast. In general, its use is not encouraged and instead the `K` member function templates should be used. + +[horizontal] +Returns:;; An iterator pointing to an element with key equivalent to `k`, or `b.end()` if no such element exists. +Notes:;; The templated overloads containing `CompatibleKey`, `CompatibleHash` and `CompatiblePredicate` are non-standard extensions which allow you to use a compatible hash function and equality predicate for a key of a different type in order to avoid an expensive type cast. In general, its use is not encouraged and instead the `K` member function templates should be used. + ++ The `template ` overloads only participate in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. --- -==== contains -```c++ -template -bool contains(K const& key); -bool contains(key_type const& key) const; -``` - -Returns:: A boolean indicating whether or not there is an element with key equal to `key` in the container - -Notes:: The `template ` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. - ---- - ==== count ```c++ -template -size_type count(K const& k) const; -size_type count(key_type const& k) const; +size_type count(const key_type& k) const; +template + size_type count(const K& k) const; ``` -Returns:: The number of elements with key equivalent to `k`. +[horizontal] +Returns:;; The number of elements with key equivalent to `k`. +Notes:;; The `template ` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. -Notes:: The `template ` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. +--- + +==== contains +```c++ +bool contains(const key_type& k) const; +template + bool contains(const K& k) const; +``` + +[horizontal] +Returns:;; A boolean indicating whether or not there is an element with key equal to `key` in the container +Notes:;; The `template ` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. --- ==== equal_range ```c++ -std::pair -equal_range(key_type const& k); - -std::pair -equal_range(key_type const& k) const; - -template -std::pair -equal_range(K const& k); - -template -std::pair -equal_range(K const& k) const; +pair equal_range(const key_type& k); +pair equal_range(const key_type& k) const; +template + pair equal_range(const K& k); +template + pair equal_range(const K& k) const; ``` -Returns:: A range containing all elements with key equivalent to `k`. If the container doesn't contain any such elements, returns `std::make_pair(b.end(), b.end())`. - -Notes:: The `template ` overloads only participate in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. +[horizontal] +Returns:;; A range containing all elements with key equivalent to `k`. If the container doesn't contain any such elements, returns `std::make_pair(b.end(), b.end())`. +Notes:;; The `template ` overloads only participate in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. --- ==== operator++[++++]++ ```c++ -mapped_type& operator[](key_type const& k); +mapped_type& operator[](const key_type& k); +mapped_type& operator[](key_type&& k); ``` -Effects:: If the container does not already contain an elements with a key equivalent to `k`, inserts the value `std::pair(k, mapped_type())`. - -Returns:: A reference to `x.second` where `x` is the element already in the container, or the newly inserted element with a key equivalent to `k`. - -Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. +[horizontal] +Effects:;; If the container does not already contain an elements with a key equivalent to `k`, inserts the value `std::pair(k, mapped_type())`. +Returns:;; A reference to `x.second` where `x` is the element already in the container, or the newly inserted element with a key equivalent to `k`. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. --- ==== at ```c++ -Mapped& at(key_type const& k); -Mapped const& at(key_type const& k) const; +mapped_type& at(const key_type& k); +const mapped_type& at(const key_type& k) const; ``` -Returns:: A reference to `x.second` where `x` is the (unique) element whose key is equivalent to `k`. - -Throws:: An exception object of type `std::out_of_range` if no such element is present. +[horizontal] +Returns:;; A reference to `x.second` where `x` is the (unique) element whose key is equivalent to `k`. +Throws:;; An exception object of type `std::out_of_range` if no such element is present. --- @@ -1272,19 +1230,21 @@ Throws:: An exception object of type `std::out_of_range` if no such element is p ==== bucket_count ```c++ -size_type bucket_count() const; +size_type bucket_count() const noexcept; ``` -Returns:: The number of buckets. +[horizontal] +Returns:;; The number of buckets. --- ==== max_bucket_count ```c++ -size_type max_bucket_count() const; +size_type max_bucket_count() const noexcept; ``` -Returns:: An upper bound on the number of buckets. +[horizontal] +Returns:;; An upper bound on the number of buckets. --- @@ -1293,20 +1253,20 @@ Returns:: An upper bound on the number of buckets. size_type bucket_size(size_type n) const; ``` -Requires:: `n < bucket_count()` - -Returns:: The number of elements in bucket `n`. +[horizontal] +Requires:;; `n < bucket_count()` +Returns:;; The number of elements in bucket `n`. --- ==== bucket ```c++ -size_type bucket(key_type const& k) const; +size_type bucket(const key_type& k) const; ``` -Returns:: The index of the bucket which would contain an element with key `k`. - -Postconditions:: The return value is less than `bucket_count()`. +[horizontal] +Returns:;; The index of the bucket which would contain an element with key `k`. +Postconditions:;; The return value is less than `bucket_count()`. --- @@ -1317,9 +1277,9 @@ local_iterator begin(size_type n); const_local_iterator begin(size_type n) const; ``` -Requires:: `n` shall be in the range `[0, bucket_count())`. - -Returns:: A local iterator pointing the first element in the bucket with index `n`. +[horizontal] +Requires:;; `n` shall be in the range `[0, bucket_count())`. +Returns:;; A local iterator pointing the first element in the bucket with index `n`. --- @@ -1329,9 +1289,9 @@ local_iterator end(size_type n); const_local_iterator end(size_type n) const; ``` -Requires:: `n` shall be in the range `[0, bucket_count())`. - -Returns:: A local iterator pointing the 'one past the end' element in the bucket with index `n`. +[horizontal] +Requires:;; `n` shall be in the range `[0, bucket_count())`. +Returns:;; A local iterator pointing the 'one past the end' element in the bucket with index `n`. --- @@ -1340,9 +1300,9 @@ Returns:: A local iterator pointing the 'one past the end' element in the bucket const_local_iterator cbegin(size_type n) const; ``` -Requires:: `n` shall be in the range `[0, bucket_count())`. - -Returns:: A constant local iterator pointing the first element in the bucket with index `n`. +[horizontal] +Requires:;; `n` shall be in the range `[0, bucket_count())`. +Returns:;; A constant local iterator pointing the first element in the bucket with index `n`. --- @@ -1351,9 +1311,9 @@ Returns:: A constant local iterator pointing the first element in the bucket wit const_local_iterator cend(size_type n) const; ``` -Requires:: `n` shall be in the range `[0, bucket_count())`. - -Returns:: A constant local iterator pointing the 'one past the end' element in the bucket with index `n`. +[horizontal] +Requires:;; `n` shall be in the range `[0, bucket_count())`. +Returns:;; A constant local iterator pointing the 'one past the end' element in the bucket with index `n`. --- @@ -1361,20 +1321,22 @@ Returns:: A constant local iterator pointing the 'one past the end' element in t ==== load_factor ```c++ -float load_factor() const; +float load_factor() const noexcept; ``` -Returns:: The average number of elements per bucket. +[horizontal] +Returns:;; The average number of elements per bucket. --- ==== max_load_factor ```c++ -float max_load_factor() const; +float max_load_factor() const noexcept; ``` -Returns:: Returns the current maximum load factor. +[horizontal] +Returns:;; Returns the current maximum load factor. --- @@ -1383,7 +1345,8 @@ Returns:: Returns the current maximum load factor. void max_load_factor(float z); ``` -Effects:: Changes the container's maximum load factor, using `z` as a hint. +[horizontal] +Effects:;; Changes the container's maximum load factor, using `z` as a hint. --- @@ -1397,7 +1360,8 @@ Changes the number of buckets so that there at least `n` buckets, and so that th Invalidates iterators, and changes the order of elements. Pointers and references to elements are not invalidated. -Throws:: The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function. +[horizontal] +Throws:;; The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function. --- @@ -1408,60 +1372,56 @@ void reserve(size_type n); Invalidates iterators, and changes the order of elements. Pointers and references to elements are not invalidated. -Throws:: The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function. +[horizontal] +Throws:;; The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function. === Equality Comparisons ==== operator== ```c++ -template< - typename Key, - typename Mapped, - typename Hash, - typename Pred, - typename Alloc> -bool operator==(unordered_map const& x, - unordered_map const& y); +template + bool operator==(const unordered_map& x, + const unordered_map& y); ``` Return `true` if `x.size() == y.size()` and for every element in `x`, there is an element in `y` with the same key, with an equal value (using `operator==` to compare the value types). -Notes:: The behavior of this function was changed to match the C++11 standard in Boost 1.48. Behavior is undefined if the two containers don't have equivalent equality predicates. +[horizontal] +Notes:;; The behavior of this function was changed to match the C++11 standard in Boost 1.48. + ++ +Behavior is undefined if the two containers don't have equivalent equality predicates. --- ==== operator!= ```c++ -template< - typename Key, - typename Mapped, - typename Hash, - typename Pred, - typename Alloc> -bool operator!=(unordered_map const& x, - unordered_map const& y); +template + bool operator!=(const unordered_map& x, + const unordered_map& y); ``` Return `false` if `x.size() == y.size()` and for every element in `x`, there is an element in `y` with the same key, with an equal value (using `operator==` to compare the value types). -Notes:: The behavior of this function was changed to match the C++11 standard in Boost 1.48. Behavior is undefined if the two containers don't have equivalent equality predicates. +[horizontal] +Notes:;; The behavior of this function was changed to match the C++11 standard in Boost 1.48. + ++ +Behavior is undefined if the two containers don't have equivalent equality predicates. === Swap ```c++ -template -void swap(unordered_map& x, - unordered_map& y); +template + void swap(unordered_map& x, + unordered_map& y) + noexcept(noexcept(x.swap(y))); ``` Swaps the contents of `x` and `y`. If `Allocator::propagate_on_container_swap` is declared and `Allocator::propagate_on_container_swap::value` is `true` then the containers' allocators are swapped. Otherwise, swapping with unequal allocators results in undefined behavior. -Effects:: `x.swap(y)` - -Throws:: Doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of `key_equal` or `hasher`. - -Notes:: The exception specifications aren't quite the same as the C++11 standard, as the equality predicate and hash function are swapped using their copy constructors. +[horizontal] +Effects:;; `x.swap(y)` +Throws:;; Doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of `key_equal` or `hasher`. +Notes:;; The exception specifications aren't quite the same as the C++11 standard, as the equality predicate and hash function are swapped using their copy constructors. diff --git a/doc/unordered/unordered_multimap.adoc b/doc/unordered/unordered_multimap.adoc index 8952cb74..8eb8fb30 100644 --- a/doc/unordered/unordered_multimap.adoc +++ b/doc/unordered/unordered_multimap.adoc @@ -7,271 +7,192 @@ === Synopsis -[source,c++,subs=+quotes] +[listing,subs="+macros,+quotes"] ----- // #include -template< - typename Key, - typename Mapped, - typename Hash = boost::hash, - typename Pred = std::equal_to, - typename Alloc = std::allocator> > -class unordered_multimap { -public: - // types - typedef Key key_type; - typedef std::pair value_type; - typedef Mapped mapped_type; - typedef Hash hasher; - typedef Pred key_equal; - typedef Alloc allocator_type; - typedef typename allocator_type::pointer pointer; - typedef typename allocator_type::const_pointer const_pointer; - typedef value_type& reference; - typedef value_type const& const_reference; - typedef _implementation-defined_ size_type; - typedef _implementation-defined_ difference_type; - typedef _implementation-defined_ iterator; - typedef _implementation-defined_ const_iterator; - typedef _implementation-defined_ local_iterator; - typedef _implementation-defined_ const_local_iterator; - typedef _implementation-defined_ node_type; - typedef _implementation-defined_ insert_return_type; +namespace boost { + template, + class Pred = std::equal_to, + class Allocator = std::allocator>> + class unordered_multimap { + public: + // types + using key_type = Key; + using mapped_type = T; + using value_type = std::pair; + using hasher = Hash; + using key_equal = Pred; + using allocator_type = Allocator; + using pointer = typename boost::allocator_traits::pointer; + using const_pointer = typename boost::allocator_traits::const_pointer; + using reference = value_type&; + using const_reference = const value_type&; + using size_type = _implementation-defined_; + using difference_type = _implementation-defined_; - // construct/copy/destruct - unordered_multimap(); + using iterator = _implementation-defined_; + using const_iterator = _implementation-defined_; + using local_iterator = _implementation-defined_; + using const_local_iterator = _implementation-defined_; + using node_type = _implementation-defined_; - explicit unordered_multimap(size_type n, - hasher const& hf = hasher(), - key_equal const& eq = key_equal(), - allocator_type const& a = allocator_type()); + // construct/copy/destroy + xref:#unordered_multimap_default_constructor[unordered_multimap](); + explicit xref:#unordered_multimap_bucket_count_constructor[unordered_multimap](size_type n, + const hasher& hf = hasher(), + const key_equal& eql = key_equal(), + const allocator_type& a = allocator_type()); + template + xref:#unordered_multimap_iterator_range_constructor[unordered_multimap](InputIterator f, InputIterator l, + size_type n = _implementation-defined_, + const hasher& hf = hasher(), + const key_equal& eql = key_equal(), + const allocator_type& a = allocator_type()); + xref:#unordered_multimap_copy_constructor[unordered_multimap](const unordered_multimap& other); + xref:#unordered_multimap_move_constructor[unordered_multimap](unordered_multimap&& other); + explicit xref:#unordered_multimap_allocator_constructor[unordered_multimap](const Allocator& a); + xref:#unordered_multimap_copy_constructor_with_allocator[unordered_multimap](const unordered_multimap& other, const Allocator& a); + xref:#unordered_multimap_move_constructor_with_allocator[unordered_multimap](unordered_multimap&& other, const Allocator& a); + xref:#unordered_multimap_initializer_list_constructor[unordered_multimap](initializer_list il, + size_type n = _implementation-defined_, + const hasher& hf = hasher(), + const key_equal& eql = key_equal(), + const allocator_type& a = allocator_type()); + xref:#unordered_multimap_bucket_count_constructor_with_allocator[unordered_multimap](size_type n, const allocator_type& a); + xref:#unordered_multimap_bucket_count_constructor_with_hasher_and_allocator[unordered_multimap](size_type n, const hasher& hf, const allocator_type& a); + template + xref:#unordered_multimap_iterator_range_constructor_with_bucket_count_and_allocator[unordered_multimap](InputIterator f, InputIterator l, size_type n, const allocator_type& a); + template + xref:#unordered_multimap_iterator_range_constructor_with_bucket_count_and_hasher[unordered_multimap](InputIterator f, InputIterator l, size_type n, const hasher& hf, + const allocator_type& a); + xref:#unordered_multimap_initializer_list_constructor[unordered_multimap](initializer_list il, size_type n, const hasher& hf, + const allocator_type& a); + xref:#unordered_multimap_destructor[~unordered_multimap](); + unordered_multimap& xref:#unordered_multimap_copy_assignment[operator++=++](const unordered_multimap& other); + unordered_multimap& xref:#unordered_multimap_move_assignment[operator++=++](unordered_multimap&& other) + noexcept(boost::allocator_traits::is_always_equal::value && + boost::is_nothrow_move_assignable_v && + boost::is_nothrow_move_assignable_v); + unordered_multimap& xref:#unordered_multimap_initializer_list_assignment[operator++=++](initializer_list il); + allocator_type xref:#unordered_multimap_get_allocator[get_allocator]() const noexcept; - unordered_multimap(unordered_multimap const& other); - unordered_multimap(unordered_multimap&& other); + // iterators + iterator xref:#unordered_multimap_begin[begin]() noexcept; + const_iterator xref:#unordered_multimap_begin[begin]() const noexcept; + iterator xref:#unordered_multimap_end[end]() noexcept; + const_iterator xref:#unordered_multimap_end[end]() const noexcept; + const_iterator xref:#unordered_multimap_cbegin[cbegin]() const noexcept; + const_iterator xref:#unordered_multimap_cend[cend]() const noexcept; - explicit unordered_multimap(Allocator const& a); - unordered_multimap(unordered_multimap const& other, Allocator const& a); - unordered_multimap(unordered_multimap&& other, Allocator const& a); + // capacity + bool xref:#unordered_multimap_empty[empty]() const noexcept; + size_type xref:#unordered_multimap_size[size]() const noexcept; + size_type xref:#unordered_multimap_max_size[max_size]() const noexcept; - unordered_multimap(size_type n, allocator_type const& a); - unordered_multimap(size_type n, hasher const& hf, allocator_type const& a); + // modifiers + template iterator xref:#unordered_multimap_emplace[emplace](Args&&... args); + template iterator xref:#unordered_multimap_emplace_hint[emplace_hint](const_iterator position, Args&&... args); + iterator xref:#unordered_multimap_copy_insert[insert](const value_type& obj); + iterator xref:#unordered_multimap_move_insert[insert](value_type&& obj); + template iterator xref:#unordered_multimap_emplace_insert[insert](P&& obj); + iterator xref:#unordered_multimap_copy_insert_with_hint[insert](const_iterator hint, const value_type& obj); + iterator xref:#unordered_multimap_move_insert_with_hint[insert](const_iterator hint, value_type&& obj); + template iterator xref:#unordered_multimap_emplace_insert_with_hint[insert](const_iterator hint, P&& obj); + template void xref:#unordered_multimap_insert_iterator_range[insert](InputIterator first, InputIterator last); + void xref:#unordered_multimap_insert_initializer_list[insert](initializer_list il); - unordered_multimap(initializer_list il, - size_type n = _implementation-defined_, - hasher const& hf = hasher(), - key_equal const& eq = key_equal(), - allocator_type const& a = allocator_type()); + node_type xref:#unordered_multimap_extract_by_iterator[extract](const_iterator position); + node_type xref:#unordered_multimap_extract_by_key[extract](const key_type& k); + template node_type xref:#unordered_multimap_transparent_extract_by_key[extract](K&& k); + iterator xref:#unordered_multimap_insert_with_node_handle[insert](node_type&& nh); + iterator xref:#unordered_multimap_insert_with_hint_and_node_handle[insert](const_iterator hint, node_type&& nh); - template - unordered_multimap(InputIterator f, - InputIterator l, - size_type n = _implementation-defined_, - hasher const& hf = hasher(), - key_equal const& eq = key_equal(), - allocator_type const& a = allocator_type()); + iterator xref:#unordered_multimap_erase_by_position[erase](iterator position); + iterator xref:#unordered_multimap_erase_by_position[erase](const_iterator position); + size_type xref:#unordered_multimap_erase_by_key[erase](const key_type& k); + template size_type xref:#unordered_multimap_transparent_erase_by_key[erase](K&& k); + iterator xref:#unordered_multimap_erase_range[erase](const_iterator first, const_iterator last); + void xref:#unordered_multimap_quick_erase[quick_erase](const_iterator position); + void xref:#unordered_multimap_erase_return_void[erase_return_void](const_iterator position); + void xref:#unordered_multimap_swap[swap](unordered_multimap& other) + noexcept(boost::allocator_traits::is_always_equal::value && + boost::is_nothrow_swappable_v && + boost::is_nothrow_swappable_v); + void xref:#unordered_multimap_clear[clear]() noexcept; - template - unordered_multimap(InputIterator f, - InputIterator l, - size_type n, - allocator_type const& a); + template + void xref:#unordered_multimap_merge[merge](unordered_multimap& source); + template + void xref:#unordered_multimap_merge_rvalue_reference[merge](unordered_multimap&& source); - template - unordered_multimap(InputIterator f, - InputIterator l, - size_type n, - hasher const& hf, - allocator_type const& a); + // observers + hasher xref:#unordered_multimap_hash_function[hash_function]() const; + key_equal xref:#unordered_multimap_key_eq[key_eq]() const; - ~unordered_multimap(); + // map operations + iterator xref:#unordered_multimap_find[find](const key_type& k); + const_iterator xref:#unordered_multimap_find[find](const key_type& k) const; + template + iterator xref:#unordered_multimap_find[find](const K& k); + template + const_iterator xref:#unordered_multimap_find[find](const K& k) const; + template + iterator xref:#unordered_multimap_find[find](CompatibleKey const& k, CompatibleHash const& hash, + CompatiblePredicate const& eq); + template + const_iterator xref:#unordered_multimap_find[find](CompatibleKey const& k, CompatibleHash const& hash, + CompatiblePredicate const& eq) const; + size_type xref:#unordered_multimap_count[count](const key_type& k) const; + template + size_type xref:#unordered_multimap_count[count](const K& k) const; + bool xref:#unordered_multimap_contains[contains](const key_type& k) const; + template + bool xref:#unordered_multimap_contains[contains](const K& k) const; + pair xref:#unordered_multimap_equal_range[equal_range](const key_type& k); + pair xref:#unordered_multimap_equal_range[equal_range](const key_type& k) const; + template + pair xref:#unordered_multimap_equal_range[equal_range](const K& k); + template + pair xref:#unordered_multimap_equal_range[equal_range](const K& k) const; - unordered_multimap& operator=(unordered_multimap const& other); - unordered_multimap& operator=(unordered_multimap&& other); - unordered_multimap& operator=(initializer_list il); + // bucket interface + size_type xref:#unordered_multimap_bucket_count[bucket_count]() const noexcept; + size_type xref:#unordered_multimap_max_bucket_count[max_bucket_count]() const noexcept; + size_type xref:#unordered_multimap_bucket_size[bucket_size](size_type n) const; + size_type xref:#unordered_multimap_bucket[bucket](const key_type& k) const; + local_iterator xref:#unordered_multimap_begin_2[begin](size_type n); + const_local_iterator xref:#unordered_multimap_begin_2[begin](size_type n) const; + local_iterator xref:#unordered_multimap_end_2[end](size_type n); + const_local_iterator xref:#unordered_multimap_end_2[end](size_type n) const; + const_local_iterator xref:#unordered_multimap_cbegin_2[cbegin](size_type n) const; + const_local_iterator xref:#unordered_multimap_cend_2[cend](size_type n) const; - // size and capacity - bool empty() const; - size_type size() const; - size_type max_size() const; - - // iterators - iterator begin(); - const_iterator begin() const; - - iterator end(); - const_iterator end() const; - - const_iterator cbegin() const; - const_iterator cend() const; - - // modifiers - template - iterator - emplace(Args&&... args); - - template - iterator - emplace_hint(const_iterator hint, Args&&... args); - - iterator - insert(value_type const& obj); - - iterator - insert(value_type&& obj); - - template - iterator - insert(P&& value); - - insert_return_type insert(node_type&& nh); - - iterator insert(const_iterator hint, value_type const& obj); - iterator insert(const_iterator hint, value_type&& obj); - iterator insert(const_iterator hint, node_type&& nh); - - template - iterator - insert(const_iterator hint, P&& value); - - template - void insert(InputIterator first, InputIterator last); - - void insert(initializer_list il); - - node_type extract(const_iterator position); - node_type extract(key_type const& k); - - template - node_type extract(K&& k); - - iterator erase(const_iterator position); - iterator erase(const_iterator first, const_iterator last); - size_type erase(key_type const& k); - - template - size_type erase(K&& k); - - void quick_erase(const_iterator position); - void erase_return_void(const_iterator position); - - void clear(); - void swap(unordered_multimap& other); - - template - void merge(unordered_multimap& source); - - template - void merge(unordered_multimap&& source); - - // observers - allocator_type get_allocator() const; - hasher hash_function() const; - key_equal key_eq() const; - - // lookup - iterator find(key_type const& k); - const_iterator find(key_type const& k) const; - - template - iterator - find(K const& k); - - template - const_iterator - find(K const& k) const; - - template< - typename CompatibleKey, - typename CompatibleHash, - typename CompatiblePredicate> - iterator - find(CompatibleKey const& k, - CompatibleHash const& hash, - CompatiblePredicate const&) eq; - - template< - typename CompatibleKey, - typename CompatibleHash, - typename CompatiblePredicate> - const_iterator - find(CompatibleKey const& k, - CompatibleHash const& hash, - CompatiblePredicate const& eq) const; - - bool contains(key_type const& key) const; - - template - bool contains(K const& key); - - size_type count(key_type const& k) const; - - template - size_type count(K const& k) const; - - std::pair - equal_range(key_type const& k); - - std::pair - equal_range(key_type const& k) const; - - template - std::pair - equal_range(K const& k); - - template - std::pair - equal_range(K const& k) const; - - // bucket interface - size_type bucket_count() const; - size_type max_bucket_count() const; - size_type bucket_size(size_type n) const; - size_type bucket(key_type const& k) const; - - local_iterator begin(size_type n); - const_local_iterator begin(size_type n) const; - - local_iterator end(size_type n); - const_local_iterator end(size_type n) const; - - const_local_iterator cbegin(size_type n) const; - const_local_iterator cend(size_type n) const; - - // hash policy - float load_factor() const; - float max_load_factor() const; - - void max_load_factor(float z); - - void rehash(size_type n); - void reserve(size_type n); -}; + // hash policy + float xref:#unordered_multimap_load_factor[load_factor]() const noexcept; + float xref:#unordered_multimap_max_load_factor[max_load_factor]() const noexcept; + void xref:#unordered_multimap_max_load_factor[max_load_factor](float z); + void xref:#unordered_multimap_rehash[rehash](size_type n); + void xref:#unordered_multimap_reserve[reserve](size_type n); + }; +} // Equality Comparisons -template< - typename Key, - typename Mapped, - typename Hash, - typename Pred, - typename Alloc> -bool operator==(unordered_multimap const& x, - unordered_multimap const& y); +template + bool xref:#unordered_multimap_operator[operator++==++](const unordered_multimap& x, + const unordered_multimap& y); -template< - typename Key, - typename Mapped, - typename Hash, - typename Pred, - typename Alloc> -bool operator!=(unordered_multimap const& x, - unordered_multimap const& y); +template + bool xref:#unordered_multimap_operator_2[operator!=](const unordered_multimap& x, + const unordered_multimap& y); // swap -template -void swap(unordered_multimap& x, - unordered_multimap& y); +template + void xref:#unordered_multimap_swap_2[swap](unordered_multimap& x, + unordered_multimap& y) + noexcept(noexcept(x.swap(y))); ----- --- @@ -286,8 +207,8 @@ void swap(unordered_multimap& x, |_Key_ |`Key` must be https://en.cppreference.com/w/cpp/named_req/Erasable[Erasable^] from the container (i.e. `allocator_traits` can destroy it). -|_Mapped_ -|`Mapped` must be https://en.cppreference.com/w/cpp/named_req/Erasable[Erasable^] from the container (i.e. `allocator_traits` can destroy it). +|_T_ +|`T` must be https://en.cppreference.com/w/cpp/named_req/Erasable[Erasable^] from the container (i.e. `allocator_traits` can destroy it). |_Hash_ |A unary function object type that acts a hash function for a `Key`. It takes a single argument of type `Key` and returns a value of type `std::size_t`. @@ -295,7 +216,7 @@ void swap(unordered_multimap& x, |_Pred_ |A binary function object that implements an equivalence relation on values of type `Key`. A binary function object that induces an equivalence relation on values of type `Key`. It takes two arguments of type `Key` and returns a value of type bool. -|_Alloc_ +|_Allocator_ |An allocator whose value type is the same as the container's value type. |=== @@ -402,15 +323,6 @@ See node_handle_map for details. --- -[source,c++,subs=+quotes] ----- -typedef _implementation-defined_ insert_return_type; ----- - -Structure returned by inserting node_type. - ---- - === Constructors ==== Default Constructor @@ -422,39 +334,59 @@ Constructs an empty container using `hasher()` as the hash function, `key_equal()` as the key equality predicate, `allocator_type()` as the allocator and a maximum load factor of `1.0`. -Postconditions:: `size() == 0` -Requires:: If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. +[horizontal] +Postconditions:;; `size() == 0` +Requires:;; If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. --- ==== Bucket Count Constructor ```c++ explicit unordered_multimap(size_type n, - hasher const& hf = hasher(), - key_equal const& eq = key_equal(), - allocator_type const& a = allocator_type()); + const hasher& hf = hasher(), + const key_equal& eql = key_equal(), + const allocator_type& a = allocator_type()); ``` Constructs an empty container with at least `n` buckets, using `hf` as the hash -function, `eq` as the key equality predicate, `a` as the allocator and a maximum +function, `eql` as the key equality predicate, `a` as the allocator and a maximum load factor of `1.0`. -Postconditions:: `size() == 0` +[horizontal] +Postconditions:;; `size() == 0` +Requires:;; If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. -Requires:: If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. +--- + +==== Iterator Range Constructor +[source,c++,subs="+quotes"] +---- +template +unordered_multimap(InputIterator f, InputIterator l, + size_type n = _implementation-defined_, + const hasher& hf = hasher(), + const key_equal& eql = key_equal(), + const allocator_type& a = allocator_type()); +---- + +Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `eql` as the key equality predicate, `a` as the allocator and a maximum load factor of `1.0` and inserts the elements from `[f, l)` into it. + +[horizontal] +Requires:;; If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. --- ==== Copy Constructor ```c++ -unordered_multimap(unordered_multimap const& other); +unordered_multimap(const unordered_multimap& other); ``` The copy constructor. Copies the contained elements, hash function, predicate, maximum load factor and allocator. If `Allocator::select_on_container_copy_construction` exists and has the right signature, the allocator will be constructed from its result. -Requires:: `value_type` is copy constructible +[horizontal] +Requires:;; `value_type` is copy constructible --- @@ -465,16 +397,18 @@ unordered_multimap(unordered_multimap&& other); The move constructor. -Notes:: This is implemented using Boost.Move. - -Requires:: `value_type` is move-constructible. On compilers without rvalue reference support the emulation does not support moving without calling `boost::move` if `value_type` is not copyable. +[horizontal] +Notes:;; This is implemented using Boost.Move. +Requires:;; `value_type` is move-constructible. + ++ +On compilers without rvalue reference support the emulation does not support moving without calling `boost::move` if `value_type` is not copyable. So, for example, you can't return the container from a function. --- ==== Allocator Constructor ```c++ -explicit unordered_multimap(Allocator const& a); +explicit unordered_multimap(const Allocator& a); ``` Constructs an empty container, using allocator `a`. @@ -483,7 +417,7 @@ Constructs an empty container, using allocator `a`. ==== Copy Constructor with Allocator ```c++ -unordered_multimap(unordered_multimap const& other, Allocator const& a); +unordered_multimap(const unordered_multimap& other, const Allocator& a); ``` Constructs an container, copying ``other``'s contained elements, hash function, predicate, maximum load factor, but using allocator `a`. @@ -492,102 +426,85 @@ Constructs an container, copying ``other``'s contained elements, hash function, ==== Move Constructor with Allocator ```c++ -unordered_multimap(unordered_multimap&& other, Allocator const& a); +unordered_multimap(unordered_multimap&& other, const Allocator& a); ``` Construct a container moving ``other``'s contained elements, and having the hash function, predicate and maximum load factor, but using allocate `a`. -Notes:: This is implemented using Boost.Move. -Requires:: `value_type` is move insertable. +[horizontal] +Notes:;; This is implemented using Boost.Move. +Requires:;; `value_type` is move insertable. --- +==== Initializer List Constructor +[source,c++,subs="+quotes"] +---- +unordered_multimap(initializer_list il, + size_type n = _implementation-defined_, + const hasher& hf = hasher(), + const key_equal& eql = key_equal(), + const allocator_type& a = allocator_type()); +---- + +Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `eql` as the key equality predicate, `a` as the allocator and a maximum load factor of `1.0` and inserts the elements from `il` into it. + +[horizontal] +Requires:;; If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. + +--- ==== Bucket Count Constructor with Allocator ```c++ -unordered_multimap(size_type n, allocator_type const& a); +unordered_multimap(size_type n, const allocator_type& a); ``` Constructs an empty container with at least `n` buckets, using `hf` as the hash function, the default hash function and key equality predicate, `a` as the allocator and a maximum load factor of `1.0`. -Postconditions:: `size() == 0` -Requires:: `hasher` and `key_equal` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. +[horizontal] +Postconditions:;; `size() == 0` +Requires:;; `hasher` and `key_equal` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. --- ==== Bucket Count Constructor with Hasher and Allocator ```c++ -unordered_multimap(size_type n, hasher const& hf, allocator_type const& a); +unordered_multimap(size_type n, const hasher& hf, const allocator_type& a); ``` Constructs an empty container with at least `n` buckets, using `hf` as the hash function, the default key equality predicate, `a` as the allocator and a maximum load factor of `1.0`. -Postconditions:: `size() == 0` -Requires:: `key_equal` needs to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. - ---- - -==== Initializer List Constructor -[source,c++,subs="quotes,macros"] ----- -unordered_multimap(initializer_list++<++value_type++>++ il, - size_type n = _implementation-defined_, - hasher const& hf = hasher(), - key_equal const& eq = key_equal(), - allocator_type const& a = allocator_type()); ----- - -Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `eq` as the key equality predicate, `a` as the allocator and a maximum load factor of `1.0` and inserts the elements from `il` into it. - -Requires:: If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. - ---- - -==== Iterator Range Constructor -[source,c++,subs="quotes,macros"] ----- -template++<++typename InputIterator++>++ -unordered_multimap(InputIterator f, - InputIterator l, - size_type n = _implementation-defined_, - hasher const& hf = hasher(), - key_equal const& eq = key_equal(), - allocator_type const& a = allocator_type()); ----- - -Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `eq` as the key equality predicate, `a` as the allocator and a maximum load factor of `1.0` and inserts the elements from `[f, l)` into it. - -Requires:: If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. +[horizontal] +Postconditions:;; `size() == 0` +Requires:;; `key_equal` needs to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. --- ==== Iterator Range Constructor with Bucket Count and Allocator -[source,c++,subs="quotes,macros"] +[source,c++,subs="+quotes"] ---- -template++<++typename InputIterator++>++ -unordered_multimap(InputIterator f, - InputIterator l, - size_type n, - allocator_type const& a); +template + unordered_multimap(InputIterator f, InputIterator l, size_type n, const allocator_type& a); ---- Constructs an empty container with at least `n` buckets, using `a` as the allocator, with the default hash function and key equality predicate and a maximum load factor of `1.0` and inserts the elements from `[f, l)` into it. -Requires:: `hasher`, `key_equal` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. +[horizontal] +Requires:;; `hasher`, `key_equal` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. + +--- ==== Iterator Range Constructor with Bucket Count and Hasher -[source,c++,subs="quotes,macros"] +[source,c++,subs="+quotes"] ---- -template++<++typename InputIterator++>++ -unordered_multimap(InputIterator f, - InputIterator l, - size_type n, - hasher const& hf, - allocator_type const& a); +template + unordered_multimap(InputIterator f, InputIterator l, size_type n, const hasher& hf, + const allocator_type& a); ---- Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `a` as the allocator, with the default key equality predicate and a maximum load factor of `1.0` and inserts the elements from `[f, l)` into it. -Requires:: `key_equal` needs to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. +[horizontal] +Requires:;; `key_equal` needs to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. --- @@ -596,7 +513,9 @@ Requires:: `key_equal` needs to be https://en.cppreference.com/w/cpp/named_req/D ```c++ ~unordered_multimap(); ``` -Note:: The destructor is applied to every element, and all memory is deallocated + +[horizontal] +Note:;; The destructor is applied to every element, and all memory is deallocated --- @@ -605,28 +524,32 @@ Note:: The destructor is applied to every element, and all memory is deallocated ==== Copy Assignment ```c++ -unordered_multimap& operator=(unordered_multimap const& other); +unordered_multimap& operator=(const unordered_multimap& other); ``` The assignment operator. Copies the contained elements, hash function, predicate and maximum load factor but not the allocator. If `Alloc::propagate_on_container_copy_assignment` exists and `Alloc::propagate_on_container_copy_assignment::value` is `true`, the allocator is overwritten, if not the copied elements are created using the existing allocator. -Requires:: `value_type` is copy constructible +[horizontal] +Requires:;; `value_type` is copy constructible --- ==== Move Assignment ```c++ -unordered_multimap& operator=(unordered_multimap&& other); +unordered_multimap& operator=(unordered_multimap&& other) + noexcept(boost::allocator_traits::is_always_equal::value && + boost::is_nothrow_move_assignable_v && + boost::is_nothrow_move_assignable_v); ``` The move assignment operator. If `Alloc::propagate_on_container_move_assignment` exists and `Alloc::propagate_on_container_move_assignment::value` is `true`, the allocator is overwritten, if not the moved elements are created using the existing allocator. -Notes:: On compilers without rvalue references, this is emulated using Boost.Move. Note that on some compilers the copy assignment operator may be used in some circumstances. - -Requires:: `value_type` is move constructible. +[horizontal] +Notes:;; On compilers without rvalue references, this is emulated using Boost.Move. Note that on some compilers the copy assignment operator may be used in some circumstances. +Requires:;; `value_type` is move constructible. --- @@ -637,76 +560,85 @@ unordered_multimap& operator=(initializer_list il); Assign from values in initializer list. All existing elements are either overwritten by the new elements or destroyed. -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^] into the container and https://en.cppreference.com/w/cpp/named_req/CopyAssignable[CopyAssignable^]. +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^] into the container and https://en.cppreference.com/w/cpp/named_req/CopyAssignable[CopyAssignable^]. + +=== Iterators + +==== begin +```c++ +iterator begin() noexcept; +const_iterator begin() const noexcept; +``` + +[horizontal] +Returns:;; An iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container. + +--- + +==== end +```c++ +iterator end() noexcept; +const_iterator end() const noexcept; +``` + +[horizontal] +Returns:;; An iterator which refers to the past-the-end value for the container. + +--- + +==== cbegin +```c++ +const_iterator cbegin() const noexcept; +``` + +[horizontal] +Returns:;; A `const_iterator` referring to the first element of the container, or if the container is empty the past-the-end value for the container. + +--- + +==== cend +```c++ +const_iterator cend() const noexcept; +``` + +[horizontal] +Returns:;; A `const_iterator` which refers to the past-the-end value for the container. + +--- === Size and Capacity ==== empty ```c++ -bool empty() const; +bool empty() const noexcept; ``` -Returns:: `size() == 0` +[horizontal] +Returns:;; `size() == 0` --- ==== size ```c++ -size_type size() const; +size_type size() const noexcept; ``` -Returns:: `std::distance(begin(), end())` +[horizontal] +Returns:;; `std::distance(begin(), end())` --- ==== max_size ```c++ -size_type max_size() const; +size_type max_size() const noexcept; ``` -Returns:: `size()` of the largest possible container. - ---- - -=== Iterators - -==== begin -```c++ -iterator begin(); -const_iterator begin() const; -``` - -Returns:: An iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container. - ---- - -==== end -```c++ -iterator end(); -const_iterator end() const; -``` - -Returns:: An iterator which refers to the past-the-end value for the container. - ---- - -==== cbegin -```c++ -const_iterator cbegin() const; -``` -Returns:: A `const_iterator` referring to the first element of the container, or if the container is empty the past-the-end value for the container. - ---- - -==== cend -```c++ -const_iterator cend() const; -``` - -Returns:: A `const_iterator` which refers to the past-the-end value for the container. +[horizontal] +Returns:;; `size()` of the largest possible container. --- @@ -714,137 +646,115 @@ Returns:: A `const_iterator` which refers to the past-the-end value for the cont ==== emplace ```c++ -template -iterator -emplace(Args&&... args); +template iterator emplace(Args&&... args); ``` Inserts an object, constructed with the arguments `args`, in the container. -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `args`. - -Returns:: An iterator pointing to the inserted element. - -Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. -Pointers and references to elements are never invalidated. -If the compiler doesn't support variadic template arguments or rvalue references, this is emulated for up to `10` arguments, with no support for rvalue references or move semantics. +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `args`. +Returns:;; An iterator pointing to the inserted element. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. + ++ +If the compiler doesn't support variadic template arguments or rvalue references, this is emulated for up to `10` arguments, with no support for rvalue references or move semantics. + ++ Since existing `std::pair` implementations don't support `std::piecewise_construct` this emulates it, but using `boost::unordered::piecewise_construct`. --- ==== emplace_hint ```c++ -template -iterator -emplace_hint(const_iterator hint, Args&&... args); +template iterator emplace_hint(const_iterator position, Args&&... args); ``` Inserts an object, constructed with the arguments args, in the container. -`hint` is a suggestion to where the element should be inserted. +`position` is a suggestion to where the element should be inserted. -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `args`. - -Returns:: An iterator pointing to the inserted element. - -Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. -Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. -Pointers and references to elements are never invalidated. -If the compiler doesn't support variadic template arguments or rvalue references, this is emulated for up to 10 arguments, with no support for rvalue references or move semantics. +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `args`. +Returns:;; An iterator pointing to the inserted element. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. + ++ +Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. + ++ +If the compiler doesn't support variadic template arguments or rvalue references, this is emulated for up to 10 arguments, with no support for rvalue references or move semantics. + ++ Since existing `std::pair` implementations don't support `std::piecewise_construct` this emulates it, but using `boost::unordered::piecewise_construct`. --- ==== Copy Insert ```c++ -iterator -insert(value_type const& obj); +iterator insert(const value_type& obj); ``` Inserts `obj` in the container. -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^]. - -Returns:: An iterator pointing to the inserted element. - -Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^]. +Returns:;; An iterator pointing to the inserted element. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. --- ==== Move Insert ```c++ -iterator -insert(value_type&& obj); +iterator insert(value_type&& obj); ``` Inserts `obj` in the container. -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/MoveInsertable[MoveInsertable^]. - -Returns:: An iterator pointing to the inserted element. - -Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/MoveInsertable[MoveInsertable^]. +Returns:;; An iterator pointing to the inserted element. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. --- ==== Emplace Insert ```c++ -template -iterator -insert(P&& value); +template iterator insert(P&& obj); ``` Inserts an element into the container by performing `emplace(std::forward

(value))`. Only participates in overload resolution if `std::is_constructible::value` is `true`. -Returns:: An iterator pointing to the inserted element. - ---- - -==== Insert with `node_handle` -```c++ -insert_return_type -insert(node_type&& nh); -``` - -If `nh` is empty, has no effect. - -Otherwise inserts the element owned by `nh`. - -Requires:: `nh` is empty or `nh.get_allocator()` is equal to the container's allocator. - -Returns:: If `nh` was empty, returns `end()`. Otherwise returns an iterator pointing to the newly inserted element. - -Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. In C++17 this can be used to insert a node extracted from a compatible `unordered_map`, but that is not supported yet. +[horizontal] +Returns:;; An iterator pointing to the inserted element. --- ==== Copy Insert with Hint ```c++ -iterator insert(const_iterator hint, value_type const& obj); +iterator insert(const_iterator hint, const value_type& obj); ``` Inserts `obj` in the container. `hint` is a suggestion to where the element should be inserted. -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^]. - -Returns:: An iterator pointing to the inserted element. - -Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^]. +Returns:;; An iterator pointing to the inserted element. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. + ++ +Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. --- @@ -857,21 +767,21 @@ Inserts `obj` in the container. `hint` is a suggestion to where the element should be inserted. -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/MoveInsertable[MoveInsertable^]. - -Returns:: An iterator pointing to the inserted element. - -Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/MoveInsertable[MoveInsertable^]. +Returns:;; An iterator pointing to the inserted element. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. + ++ +Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. --- ==== Emplace Insert with Hint ```c++ -template -iterator -insert(const_iterator hint, P&& value); +template iterator insert(const_iterator hint, P&& obj); ``` Inserts an element into the container by performing `emplace_hint(hint, std::forward

(value))`. @@ -880,9 +790,111 @@ Only participates in overload resolution if `std::is_constructible void insert(InputIterator first, InputIterator last); +``` + +Inserts a range of elements into the container. + +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `*first`. +Throws:;; When inserting a single element, if an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. + +--- + +==== Insert Initializer List +```c++ +void insert(initializer_list il); +``` + +Inserts a range of elements into the container. + +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `*first`. +Throws:;; When inserting a single element, if an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. + +--- + +==== Extract by Iterator +```c++ +node_type extract(const_iterator position); +``` + +Removes the element pointed to by `position`. + +[horizontal] +Returns:;; A `node_type` owning the element. +Notes:;; In C++17 a node extracted using this method can be inserted into a compatible `unordered_map`, but that is not supported yet. + +--- + +==== Extract by Key +```c++ +node_type extract(const key_type& k); +``` + +Removes an element with key equivalent to `k`. + +[horizontal] +Returns:;; A `node_type` owning the element if found, otherwise an empty `node_type`. +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. +Notes:;; In C++17 a node extracted using this method can be inserted into a compatible `unordered_map`, but that is not supported yet. + +--- + +==== Transparent Extract by Key +```c++ +template node_type extract(K&& k); +``` + +Removes an element with key equivalent to `k`. + +This overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs and neither `iterator` nor `const_iterator` are implicitly convertible from `K`. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. + +[horizontal] +Returns:;; A `node_type` owning the element if found, otherwise an empty `node_type`. +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. +Notes:;; In C++17 a node extracted using this method can be inserted into a compatible `unordered_map`, but that is not supported yet. + +--- + +==== Insert with `node_handle` +```c++ +iterator insert(node_type&& nh); +``` + +If `nh` is empty, has no effect. + +Otherwise inserts the element owned by `nh`. + +[horizontal] +Requires:;; `nh` is empty or `nh.get_allocator()` is equal to the container's allocator. +Returns:;; If `nh` was empty, returns `end()`. + ++ +Otherwise returns an iterator pointing to the newly inserted element. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. + ++ +In C++17 this can be used to insert a node extracted from a compatible `unordered_map`, but that is not supported yet. --- @@ -897,106 +909,63 @@ Otherwise inserts the element owned by `nh`. `hint` is a suggestion to where the element should be inserted. -Requires:: `nh` is empty or `nh.get_allocator()` is equal to the container's allocator. - -Returns:: If `nh` was empty, returns `end()`. + +[horizontal] +Requires:;; `nh` is empty or `nh.get_allocator()` is equal to the container's allocator. +Returns:;; If `nh` was empty, returns `end()`. + + Otherwise returns an iterator pointing to the newly inserted element. - -Throws:: If an exception is thrown by an operation other than a call to hasher the function has no effect. - -Notes:: The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. In C++17 this can be used to insert a node extracted from a compatible `unordered_map`, but that is not supported yet. +Throws:;; If an exception is thrown by an operation other than a call to hasher the function has no effect. +Notes:;; The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. + ++ +Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. + ++ +In C++17 this can be used to insert a node extracted from a compatible `unordered_map`, but that is not supported yet. --- -==== Insert Iterator Range -```c++ -template -void insert(InputIterator first, InputIterator last); -``` - -Inserts a range of elements into the container. - -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `*first`. - -Throws:: When inserting a single element, if an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. - ---- - -==== Insert Initializer List -```c++ -void insert(initializer_list il); -``` - -Inserts a range of elements into the container. - -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `*first`. - -Throws:: When inserting a single element, if an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. - ---- - -==== Extract by Iterator -```c++ -node_type extract(const_iterator position); -``` - -Removes the element pointed to by `position`. - -Returns:: A `node_type` owning the element. - -Notes:: In C++17 a node extracted using this method can be inserted into a compatible `unordered_map`, but that is not supported yet. - ---- - -==== Transparent Extract by Key -```c++ -template -node_type extract(K&& k); -``` - -Removes an element with key equivalent to `k`. - -This overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs and neither `iterator` nor `const_iterator` are implicitly convertible from `K`. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. - -Returns:: A `node_type` owning the element if found, otherwise an empty `node_type`. - -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. - -Notes:: In C++17 a node extracted using this method can be inserted into a compatible `unordered_map`, but that is not supported yet. - ---- - -==== Extract by Key -```c++ -node_type extract(key_type const& k); -``` - -Removes an element with key equivalent to `k`. - -Returns:: A `node_type` owning the element if found, otherwise an empty `node_type`. - -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. - -Notes:: In C++17 a node extracted using this method can be inserted into a compatible `unordered_map`, but that is not supported yet. - ==== Erase by Position ```c++ +iterator erase(iterator position); iterator erase(const_iterator position); ``` Erase the element pointed to by `position`. -Returns:: The iterator following `position` before the erasure. +[horizontal] +Returns:;; The iterator following `position` before the erasure. +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. +Notes:;; In older versions this could be inefficient because it had to search through several buckets to find the position of the returned iterator. The data structure has been changed so that this is no longer the case, and the alternative erase methods have been deprecated. -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. +--- -Notes:: In older versions this could be inefficient because it had to search through several buckets to find the position of the returned iterator. The data structure has been changed so that this is no longer the case, and the alternative erase methods have been deprecated. +==== Erase by Key +```c++ +size_type erase(const key_type& k); +``` + +Erase all elements with key equivalent to `k`. + +[horizontal] +Returns:;; The number of elements erased. +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. + +--- + +==== Transparent Erase by Key +```c++ +template size_type erase(K&& k); +``` + +Erase all elements with key equivalent to `k`. + +This overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs and neither `iterator` nor `const_iterator` are implicitly convertible from `K`. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. + +[horizontal] +Returns:;; The number of elements erased. +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. --- @@ -1008,38 +977,11 @@ iterator erase(const_iterator first, const_iterator last); Erases the elements in the range from `first` to `last`. -Returns:: The iterator following the erased elements - i.e. `last`. - -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations. - ---- - -==== Transparent Erase by Key -```c++ -template -size_type erase(K&& k); -``` - -Erase all elements with key equivalent to `k`. - -This overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs and neither `iterator` nor `const_iterator` are implicitly convertible from `K`. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. - -Returns:: The number of elements erased. - -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. - ---- - -==== Erase by Key -```c++ -size_type erase(key_type const& k); -``` - -Erase all elements with key equivalent to `k`. - -Returns:: The number of elements erased. - -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. +[horizontal] +Returns:;; The iterator following the erased elements - i.e. `last`. +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. + ++ +In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations. --- @@ -1050,9 +992,11 @@ void quick_erase(const_iterator position); Erase the element pointed to by `position`. -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations. - -Notes:: This method was implemented because returning an iterator to the next element from erase was expensive, but the container has been redesigned so that is no longer the case. So this method is now deprecated. +[horizontal] +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. + ++ +In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations. +Notes:;; This method was implemented because returning an iterator to the next element from erase was expensive, but the container has been redesigned so that is no longer the case. So this method is now deprecated. --- @@ -1063,57 +1007,64 @@ void erase_return_void(const_iterator position); Erase the element pointed to by `position`. -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations. - -Notes:: This method was implemented because returning an iterator to the next element from erase was expensive, but the container has been redesigned so that is no longer the case. So this method is now deprecated. - ---- - -==== clear -```c++ -void clear(); -``` - -Erases all elements in the container. - -Postconditions:: `size() == 0` - -Throws:: Never throws an exception. +[horizontal] +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. + ++ +In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations. +Notes:;; This method was implemented because returning an iterator to the next element from erase was expensive, but the container has been redesigned so that is no longer the case. So this method is now deprecated. --- ==== swap ```c++ -void swap(unordered_multimap& other); +void swap(unordered_multimap& other) + noexcept(boost::allocator_traits::is_always_equal::value && + boost::is_nothrow_swappable_v && + boost::is_nothrow_swappable_v); ``` Swaps the contents of the container with the parameter. If `Allocator::propagate_on_container_swap` is declared and `Allocator::propagate_on_container_swap::value` is `true` then the containers' allocators are swapped. Otherwise, swapping with unequal allocators results in undefined behavior. -Throws:: Doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of `key_equal` or `hasher`. +[horizontal] +Throws:;; Doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of `key_equal` or `hasher`. +Notes:;; The exception specifications aren't quite the same as the C++11 standard, as the equality predicate and hash function are swapped using their copy constructors. -Notes:: The exception specifications aren't quite the same as the C++11 standard, as the equality predicate and hash function are swapped using their copy constructors. +--- + +==== clear +```c++ +void clear() noexcept; +``` + +Erases all elements in the container. + +[horizontal] +Postconditions:;; `size() == 0` +Throws:;; Never throws an exception. --- ==== merge ```c++ -template -void merge(unordered_multimap& source); +template + void merge(unordered_multimap& source); ``` -Notes:: Does not support merging with a compatible `unordered_map` yet. +[horizontal] +Notes:;; Does not support merging with a compatible `unordered_map` yet. --- ==== merge (rvalue reference) ```c++ -template -void merge(unordered_multimap&& source); +template + void merge(unordered_multimap&& source); ``` -Notes:: Does not support merging with a compatible `unordered_map` yet. +[horizontal] +Notes:;; Does not support merging with a compatible `unordered_map` yet. --- @@ -1131,15 +1082,18 @@ allocator_type get_allocator() const; hasher hash_function() const; ``` -Returns:: The container's hash function. +[horizontal] +Returns:;; The container's hash function. --- +==== key_eq ``` key_equal key_eq() const; ``` -Returns:: The container's key equality predicate +[horizontal] +Returns:;; The container's key equality predicate --- @@ -1147,90 +1101,68 @@ Returns:: The container's key equality predicate ==== find ```c++ -iterator find(key_type const& k); -const_iterator find(key_type const& k) const; - -template -iterator -find(K const& k); - -template -const_iterator -find(K const& k) const; - -template< - typename CompatibleKey, - typename CompatibleHash, - typename CompatiblePredicate> -iterator -find(CompatibleKey const& k, - CompatibleHash const& hash, - CompatiblePredicate const& eq); - -template< - typename CompatibleKey, - typename CompatibleHash, - typename CompatiblePredicate> -const_iterator -find(CompatibleKey const& k, - CompatibleHash const& hash, - CompatiblePredicate const& eq) const; +iterator find(const key_type& k); +const_iterator find(const key_type& k) const; +template + iterator find(const K& k); +template + const_iterator find(const K& k) const; +template + iterator find(CompatibleKey const& k, CompatibleHash const& hash, + CompatiblePredicate const& eq); +template + const_iterator find(CompatibleKey const& k, CompatibleHash const& hash, + CompatiblePredicate const& eq) const; ``` -Returns:: An iterator pointing to an element with key equivalent to `k`, or `b.end()` if no such element exists. - -Notes:: The templated overloads containing `CompatibleKey`, `CompatibleHash` and `CompatiblePredicate` are non-standard extensions which allow you to use a compatible hash function and equality predicate for a key of a different type in order to avoid an expensive type cast. In general, its use is not encouraged and instead the `K` member function templates should be used. + +[horizontal] +Returns:;; An iterator pointing to an element with key equivalent to `k`, or `b.end()` if no such element exists. +Notes:;; The templated overloads containing `CompatibleKey`, `CompatibleHash` and `CompatiblePredicate` are non-standard extensions which allow you to use a compatible hash function and equality predicate for a key of a different type in order to avoid an expensive type cast. In general, its use is not encouraged and instead the `K` member function templates should be used. + ++ The `template ` overloads only participate in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. --- -==== contains -```c++ -template -bool contains(K const& key); -bool contains(key_type const& key) const; -``` - -Returns:: A boolean indicating whether or not there is an element with key equal to `key` in the container - -Notes:: The `template ` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. - ---- - ==== count ```c++ -template -size_type count(K const& k) const; -size_type count(key_type const& k) const; +size_type count(const key_type& k) const; +template + size_type count(const K& k) const; ``` -Returns:: The number of elements with key equivalent to `k`. +[horizontal] +Returns:;; The number of elements with key equivalent to `k`. +Notes:;; The `template ` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. -Notes:: The `template ` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. +--- + +==== contains +```c++ +bool contains(const key_type& k) const; +template + bool contains(const K& k) const; +``` + +[horizontal] +Returns:;; A boolean indicating whether or not there is an element with key equal to `key` in the container +Notes:;; The `template ` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. --- ==== equal_range ```c++ -std::pair -equal_range(key_type const& k); - -std::pair -equal_range(key_type const& k) const; - -template -std::pair -equal_range(K const& k); - -template -std::pair -equal_range(K const& k) const; +pair equal_range(const key_type& k); +pair equal_range(const key_type& k) const; +template + pair equal_range(const K& k); +template + pair equal_range(const K& k) const; ``` -Returns:: A range containing all elements with key equivalent to `k`. If the container doesn't contain any such elements, returns `std::make_pair(b.end(), b.end())`. - -Notes:: The `template ` overloads only participate in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. +[horizontal] +Returns:;; A range containing all elements with key equivalent to `k`. If the container doesn't contain any such elements, returns `std::make_pair(b.end(), b.end())`. +Notes:;; The `template ` overloads only participate in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. --- @@ -1238,19 +1170,21 @@ Notes:: The `template ` overloads only participate in overload resol ==== bucket_count ```c++ -size_type bucket_count() const; +size_type bucket_count() const noexcept; ``` -Returns:: The number of buckets. +[horizontal] +Returns:;; The number of buckets. --- ==== max_bucket_count ```c++ -size_type max_bucket_count() const; +size_type max_bucket_count() const noexcept; ``` -Returns:: An upper bound on the number of buckets. +[horizontal] +Returns:;; An upper bound on the number of buckets. --- @@ -1259,20 +1193,20 @@ Returns:: An upper bound on the number of buckets. size_type bucket_size(size_type n) const; ``` -Requires:: `n < bucket_count()` - -Returns:: The number of elements in bucket `n`. +[horizontal] +Requires:;; `n < bucket_count()` +Returns:;; The number of elements in bucket `n`. --- ==== bucket ```c++ -size_type bucket(key_type const& k) const; +size_type bucket(const key_type& k) const; ``` -Returns:: The index of the bucket which would contain an element with key `k`. - -Postconditions:: The return value is less than `bucket_count()`. +[horizontal] +Returns:;; The index of the bucket which would contain an element with key `k`. +Postconditions:;; The return value is less than `bucket_count()`. --- @@ -1283,9 +1217,9 @@ local_iterator begin(size_type n); const_local_iterator begin(size_type n) const; ``` -Requires:: `n` shall be in the range `[0, bucket_count())`. - -Returns:: A local iterator pointing the first element in the bucket with index `n`. +[horizontal] +Requires:;; `n` shall be in the range `[0, bucket_count())`. +Returns:;; A local iterator pointing the first element in the bucket with index `n`. --- @@ -1295,9 +1229,9 @@ local_iterator end(size_type n); const_local_iterator end(size_type n) const; ``` -Requires:: `n` shall be in the range `[0, bucket_count())`. - -Returns:: A local iterator pointing the 'one past the end' element in the bucket with index `n`. +[horizontal] +Requires:;; `n` shall be in the range `[0, bucket_count())`. +Returns:;; A local iterator pointing the 'one past the end' element in the bucket with index `n`. --- @@ -1306,9 +1240,9 @@ Returns:: A local iterator pointing the 'one past the end' element in the bucket const_local_iterator cbegin(size_type n) const; ``` -Requires:: `n` shall be in the range `[0, bucket_count())`. - -Returns:: A constant local iterator pointing the first element in the bucket with index `n`. +[horizontal] +Requires:;; `n` shall be in the range `[0, bucket_count())`. +Returns:;; A constant local iterator pointing the first element in the bucket with index `n`. --- @@ -1317,9 +1251,9 @@ Returns:: A constant local iterator pointing the first element in the bucket wit const_local_iterator cend(size_type n) const; ``` -Requires:: `n` shall be in the range `[0, bucket_count())`. - -Returns:: A constant local iterator pointing the 'one past the end' element in the bucket with index `n`. +[horizontal] +Requires:;; `n` shall be in the range `[0, bucket_count())`. +Returns:;; A constant local iterator pointing the 'one past the end' element in the bucket with index `n`. --- @@ -1327,20 +1261,22 @@ Returns:: A constant local iterator pointing the 'one past the end' element in t ==== load_factor ```c++ -float load_factor() const; +float load_factor() const noexcept; ``` -Returns:: The average number of elements per bucket. +[horizontal] +Returns:;; The average number of elements per bucket. --- ==== max_load_factor ```c++ -float max_load_factor() const; +float max_load_factor() const noexcept; ``` -Returns:: Returns the current maximum load factor. +[horizontal] +Returns:;; Returns the current maximum load factor. --- @@ -1349,7 +1285,8 @@ Returns:: Returns the current maximum load factor. void max_load_factor(float z); ``` -Effects:: Changes the container's maximum load factor, using `z` as a hint. +[horizontal] +Effects:;; Changes the container's maximum load factor, using `z` as a hint. --- @@ -1363,7 +1300,8 @@ Changes the number of buckets so that there at least `n` buckets, and so that th Invalidates iterators, and changes the order of elements. Pointers and references to elements are not invalidated. -Throws:: The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function. +[horizontal] +Throws:;; The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function. --- @@ -1374,60 +1312,60 @@ void reserve(size_type n); Invalidates iterators, and changes the order of elements. Pointers and references to elements are not invalidated. -Throws:: The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function. +[horizontal] +Throws:;; The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function. + +--- === Equality Comparisons ==== operator== ```c++ -template< - typename Key, - typename Mapped, - typename Hash, - typename Pred, - typename Alloc> -bool operator==(unordered_multimap const& x, - unordered_multimap const& y); +template + bool operator==(const unordered_multimap& x, + const unordered_multimap& y); ``` Return `true` if `x.size() == y.size()` and for every equivalent key group in `x`, there is a group in `y` for the same key, which is a permutation (using `operator==` to compare the value types). -Notes:: The behavior of this function was changed to match the C++11 standard in Boost 1.48. Behavior is undefined if the two containers don't have equivalent equality predicates. +[horizontal] +Notes:;; The behavior of this function was changed to match the C++11 standard in Boost 1.48. + ++ +Behavior is undefined if the two containers don't have equivalent equality predicates. --- ==== operator!= ```c++ -template< - typename Key, - typename Mapped, - typename Hash, - typename Pred, - typename Alloc> -bool operator!=(unordered_multimap const& x, - unordered_multimap const& y); +template + bool operator!=(const unordered_multimap& x, + const unordered_multimap& y); ``` Return `false` if `x.size() == y.size()` and for every equivalent key group in `x`, there is a group in `y` for the same key, which is a permutation (using `operator==` to compare the value types). -Notes:: The behavior of this function was changed to match the C++11 standard in Boost 1.48. Behavior is undefined if the two containers don't have equivalent equality predicates. +[horizontal] +Notes:;; The behavior of this function was changed to match the C++11 standard in Boost 1.48. + ++ +Behavior is undefined if the two containers don't have equivalent equality predicates. + +--- === Swap ```c++ -template -void swap(unordered_multimap& x, - unordered_multimap& y); +template + void swap(unordered_multimap& x, + unordered_multimap& y) + noexcept(noexcept(x.swap(y))); ``` Swaps the contents of `x` and `y`. If `Allocator::propagate_on_container_swap` is declared and `Allocator::propagate_on_container_swap::value` is `true` then the containers' allocators are swapped. Otherwise, swapping with unequal allocators results in undefined behavior. -Effects:: `x.swap(y)` - -Throws:: Doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of `key_equal` or `hasher`. - -Notes:: The exception specifications aren't quite the same as the C++11 standard, as the equality predicate and hash function are swapped using their copy constructors. +[horizontal] +Effects:;; `x.swap(y)` +Throws:;; Doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of `key_equal` or `hasher`. +Notes:;; The exception specifications aren't quite the same as the C++11 standard, as the equality predicate and hash function are swapped using their copy constructors. diff --git a/doc/unordered/unordered_multiset.adoc b/doc/unordered/unordered_multiset.adoc index eac97b2c..122a1b27 100644 --- a/doc/unordered/unordered_multiset.adoc +++ b/doc/unordered/unordered_multiset.adoc @@ -7,261 +7,186 @@ === Synopsis -[source,c++,subs=+quotes] +[listing,subs="+macros,+quotes"] ----- // #include -template< - typename Value, - typename Hash = boost::hash, - typename Pred = std::equal_to, - typename Alloc = std::allocator> > -class unordered_multiset { -public: - // types - typedef Value key_type; - typedef Value value_type; - typedef Hash hasher; - typedef Pred key_equal; - typedef Alloc allocator_type; - typedef typename allocator_type::pointer pointer; - typedef typename allocator_type::const_pointer const_pointer; - typedef value_type& reference; - typedef value_type const& const_reference; - typedef _implementation-defined_ size_type; - typedef _implementation-defined_ difference_type; - typedef _implementation-defined_ iterator; - typedef _implementation-defined_ const_iterator; - typedef _implementation-defined_ local_iterator; - typedef _implementation-defined_ const_local_iterator; - typedef _implementation-defined_ node_type; - typedef _implementation-defined_ insert_return_type; +namespace boost { + template, + class Pred = std::equal_to, + class Allocator = std::allocator> + class unordered_multiset { + public: + // types + using key_type = Key; + using value_type = Key; + using hasher = Hash; + using key_equal = Pred; + using allocator_type = Allocator; + using pointer = typename boost::allocator_traits::pointer; + using const_pointer = typename boost::allocator_traits::const_pointer; + using reference = value_type&; + using const_reference = const value_type&; + using size_type = _implementation-defined_; + using difference_type = _implementation-defined_; - // construct/copy/destruct - unordered_multiset(); + using iterator = _implementation-defined_; + using const_iterator = _implementation-defined_; + using local_iterator = _implementation-defined_; + using const_local_iterator = _implementation-defined_; + using node_type = _implementation-defined_; - explicit unordered_multiset(size_type n, - hasher const& hf = hasher(), - key_equal const& eq = key_equal(), - allocator_type const& a = allocator_type()); + // construct/copy/destroy + xref:#unordered_multiset_default_constructor[unordered_multiset](); + explicit xref:#unordered_multiset_bucket_count_constructor[unordered_multiset](size_type n, + const hasher& hf = hasher(), + const key_equal& eql = key_equal(), + const allocator_type& a = allocator_type()); + template + xref:#unordered_multiset_iterator_range_constructor[unordered_multiset](InputIterator f, InputIterator l, + size_type n = _implementation-defined_, + const hasher& hf = hasher(), + const key_equal& eql = key_equal(), + const allocator_type& a = allocator_type()); + xref:#unordered_multiset_copy_constructor[unordered_multiset](const unordered_multiset& other); + xref:#unordered_multiset_move_constructor[unordered_multiset](unordered_multiset&& other); + explicit xref:#unordered_multiset_allocator_constructor[unordered_multiset](const Allocator& a); + xref:#unordered_multiset_copy_constructor_with_allocator[unordered_multiset](const unordered_multiset& other, const Allocator& a); + xref:#unordered_multiset_move_constructor_with_allocator[unordered_multiset](unordered_multiset&& other, const Allocator& a); + xref:#unordered_multiset_initializer_list_constructor[unordered_multiset](initializer_list il, + size_type n = _implementation-defined_, + const hasher& hf = hasher(), + const key_equal& eql = key_equal(), + const allocator_type& a = allocator_type()); + xref:#unordered_multiset_bucket_count_constructor_with_allocator[unordered_multiset](size_type n, const allocator_type& a); + xref:#unordered_multiset_bucket_count_constructor_with_hasher_and_allocator[unordered_multiset](size_type n, const hasher& hf, const allocator_type& a); + template + xref:#unordered_multiset_iterator_range_constructor_with_bucket_count_and_allocator[unordered_multiset](InputIterator f, InputIterator l, size_type n, const allocator_type& a); + template + xref:#unordered_multiset_iterator_range_constructor_with_bucket_count_and_hasher[unordered_multiset](InputIterator f, InputIterator l, size_type n, const hasher& hf, + const allocator_type& a); + xref:#unordered_multiset_destructor[~unordered_multiset()]; + unordered_multiset& xref:#unordered_multiset_copy_assignment[operator++=++](const unordered_multiset& other); + unordered_multiset& xref:#unordered_multiset_move_assignment[operator++=++](unordered_multiset&& other) + noexcept(boost::allocator_traits::is_always_equal::value && + boost::is_nothrow_move_assignable_v && + boost::is_nothrow_move_assignable_v); + unordered_multiset& xref:#unordered_multiset_initializer_list_assignment[operator++=++](initializer_list il); + allocator_type xref:#unordered_multiset_get_allocator[get_allocator]() const noexcept; - unordered_multiset(unordered_multiset const& other); - unordered_multiset(unordered_multiset&& other); + // iterators + iterator xref:#unordered_multiset_begin[begin]() noexcept; + const_iterator xref:#unordered_multiset_begin[begin]() const noexcept; + iterator xref:#unordered_multiset_end[end]() noexcept; + const_iterator xref:#unordered_multiset_end[end]() const noexcept; + const_iterator xref:#unordered_multiset_cbegin[cbegin]() const noexcept; + const_iterator xref:#unordered_multiset_cend[cend]() const noexcept; - explicit unordered_multiset(Allocator const& a); - unordered_multiset(unordered_multiset const& other, Allocator const& a); - unordered_multiset(unordered_multiset&& other, Allocator const& a); + // capacity + bool xref:#unordered_multiset_empty[empty]() const noexcept; + size_type xref:#unordered_multiset_size[size]() const noexcept; + size_type xref:#unordered_multiset_max_size[max_size]() const noexcept; - unordered_multiset(size_type n, allocator_type const& a); - unordered_multiset(size_type n, hasher const& hf, allocator_type const& a); + // modifiers + template iterator xref:#unordered_multiset_emplace[emplace](Args&&... args); + template iterator xref:#unordered_multiset_emplace_hint[emplace_hint](const_iterator position, Args&&... args); + iterator xref:#unordered_multiset_copy_insert[insert](const value_type& obj); + iterator xref:#unordered_multiset_move_insert[insert](value_type&& obj); + iterator xref:#unordered_multiset_copy_insert_with_hint[insert](const_iterator hint, const value_type& obj); + iterator xref:#unordered_multiset_move_insert_with_hint[insert](const_iterator hint, value_type&& obj); + template void xref:#unordered_multiset_insert_iterator_range[insert](InputIterator first, InputIterator last); + void xref:#unordered_multiset_insert_initializer_list[insert](initializer_list il); - unordered_multiset(initializer_list il, - size_type n = _implementation-defined_, - hasher const& hf = hasher(), - key_equal const& eq = key_equal(), - allocator_type const& a = allocator_type()); + node_type xref:#unordered_multiset_extract_by_iterator[extract](const_iterator position); + node_type xref:#unordered_multiset_extract_by_value[extract](const key_type& k); + template node_type xref:#unordered_multiset_transparent_extract_by_value[extract](K&& k); + iterator xref:#unordered_multiset_insert_with_node_handle[insert](node_type&& nh); + iterator xref:#unordered_multiset_insert_with_hint_and_node_handle[insert](const_iterator hint, node_type&& nh); - template - unordered_multiset(InputIterator f, - InputIterator l, - size_type n = _implementation-defined_, - hasher const& hf = hasher(), - key_equal const& eq = key_equal(), - allocator_type const& a = allocator_type()); + iterator xref:#unordered_multiset_erase_by_position[erase](iterator position); + iterator xref:#unordered_multiset_erase_by_position[erase](const_iterator position); + size_type xref:#unordered_multiset_erase_by_value[erase](const key_type& k); + template size_type xref:#unordered_multiset_transparent_erase_by_value[erase](K&& x); + iterator xref:#unordered_multiset_erase_range[erase](const_iterator first, const_iterator last); + void xref:#unordered_multiset_quick_erase[quick_erase](const_iterator position); + void xref:#unordered_multiset_erase_return_void[erase_return_void](const_iterator position); + void xref:#unordered_multiset_swap[swap](unordered_multiset&) + noexcept(boost::allocator_traits::is_always_equal::value && + boost::is_nothrow_swappable_v && + boost::is_nothrow_swappable_v); + void xref:#unordered_multiset_clear[clear]() noexcept; - template - unordered_multiset(InputIterator f, - InputIterator l, - size_type n, - allocator_type const& a); + template + void xref:#unordered_multiset_merge[merge](unordered_multiset& source); + template + void xref:#unordered_multiset_merge_rvalue_reference[merge](unordered_multiset&& source); - template - unordered_multiset(InputIterator f, - InputIterator l, - size_type n, - hasher const& hf, - allocator_type const& a); + // observers + hasher xref:#unordered_multiset_hash_function[hash_function]() const; + key_equal xref:#unordered_multiset_key_eq[key_eq]() const; - ~unordered_multiset(); + // set operations + iterator xref:#unordered_multiset_find[find](const key_type& k); + const_iterator xref:#unordered_multiset_find[find](const key_type& k) const; + template + iterator xref:#unordered_multiset_find[find](const K& k); + template + const_iterator xref:#unordered_multiset_find[find](const K& k) const; + template + iterator xref:#unordered_multiset_find[find](CompatibleKey const&, CompatibleHash const&, + CompatiblePredicate const&); + template + const_iterator xref:#unordered_multiset_find[find](CompatibleKey const&, CompatibleHash const&, + CompatiblePredicate const&) const; + size_type xref:#unordered_multiset_count[count](const key_type& k) const; + template + size_type xref:#unordered_multiset_count[count](const K& k) const; + bool xref:#unordered_multiset_contains[contains](const key_type& k) const; + template + bool xref:#unordered_multiset_contains[contains](const K& k) const; + std::pair xref:#unordered_multiset_equal_range[equal_range](const key_type& k); + std::pair xref:#unordered_multiset_equal_range[equal_range](const key_type& k) const; + template + std::pair xref:#unordered_multiset_equal_range[equal_range](const K& k); + template + std::pair xref:#unordered_multiset_equal_range[equal_range](const K& k) const; - unordered_multiset& operator=(unordered_multiset const& other); - unordered_multiset& operator=(unordered_multiset&& other); - unordered_multiset& operator=(initializer_list il); + // bucket interface + size_type xref:#unordered_multiset_bucket_count[bucket_count]() const noexcept; + size_type xref:#unordered_multiset_max_bucket_count[max_bucket_count]() const noexcept; + size_type xref:#unordered_multiset_bucket_size[bucket_size](size_type n) const; + size_type xref:#unordered_multiset_bucket[bucket](const key_type& k) const; + local_iterator xref:#unordered_multiset_begin_2[begin](size_type n); + const_local_iterator xref:#unordered_multiset_begin_2[begin](size_type n) const; + local_iterator xref:#unordered_multiset_end_2[end](size_type n); + const_local_iterator xref:#unordered_multiset_end_2[end](size_type n) const; + const_local_iterator xref:#unordered_multiset_cbegin_2[cbegin](size_type n) const; + const_local_iterator xref:#unordered_multiset_cend_2[cend](size_type n) const; - // size and capacity - bool empty() const; - size_type size() const; - size_type max_size() const; - - // iterators - iterator begin(); - const_iterator begin() const; - - iterator end(); - const_iterator end() const; - - const_iterator cbegin() const; - const_iterator cend() const; - - // modifiers - template - iterator - emplace(Args&&... args); - - template - iterator - emplace_hint(const_iterator hint, Args&&... args); - - iterator - insert(value_type const& obj); - - iterator - insert(value_type&& obj); - - iterator insert(node_type&& nh); - - iterator insert(const_iterator hint, value_type const& obj); - iterator insert(const_iterator hint, value_type&& obj); - iterator insert(const_iterator hint, node_type&& nh); - - template - void insert(InputIterator first, InputIterator last); - - void insert(initializer_list il); - - node_type extract(const_iterator position); - node_type extract(key_type const& k); - - template - node_type extract(K&& k); - - iterator erase(const_iterator position); - iterator erase(const_iterator first, const_iterator last); - size_type erase(key_type const& k); - - template - size_type erase(K&& k); - - void quick_erase(const_iterator position); - void erase_return_void(const_iterator position); - - void clear(); - void swap(unordered_multiset& other); - - template - void merge(unordered_multiset& source); - - template - void merge(unordered_multiset&& source); - - // observers - allocator_type get_allocator() const; - hasher hash_function() const; - key_equal key_eq() const; - - // lookup - iterator find(key_type const& k); - const_iterator find(key_type const& k) const; - - template - iterator - find(K const& k); - - template - const_iterator - find(K const& k) const; - - template< - typename CompatibleValue, - typename CompatibleHash, - typename CompatiblePredicate> - iterator - find(CompatibleValue const& k, - CompatibleHash const& hash, - CompatiblePredicate const&) eq; - - template< - typename CompatibleValue, - typename CompatibleHash, - typename CompatiblePredicate> - const_iterator - find(CompatibleValue const& k, - CompatibleHash const& hash, - CompatiblePredicate const& eq) const; - - bool contains(key_type const& key) const; - - template - bool contains(K const& key); - - size_type count(key_type const& k) const; - - template - size_type count(K const& k) const; - - std::pair - equal_range(key_type const& k); - - std::pair - equal_range(key_type const& k) const; - - template - std::pair - equal_range(K const& k); - - template - std::pair - equal_range(K const& k) const; - - // bucket interface - size_type bucket_count() const; - size_type max_bucket_count() const; - size_type bucket_size(size_type n) const; - size_type bucket(key_type const& k) const; - - local_iterator begin(size_type n); - const_local_iterator begin(size_type n) const; - - local_iterator end(size_type n); - const_local_iterator end(size_type n) const; - - const_local_iterator cbegin(size_type n) const; - const_local_iterator cend(size_type n) const; - - // hash policy - float load_factor() const; - float max_load_factor() const; - - void max_load_factor(float z); - - void rehash(size_type n); - void reserve(size_type n); -}; + // hash policy + float xref:#unordered_multiset_load_factor[load_factor]() const noexcept; + float xref:#unordered_multiset_max_load_factor[max_load_factor]() const noexcept; + void xref:#unordered_multiset_set_max_load_factor[max_load_factor](float z); + void xref:#unordered_multiset_rehash[rehash](size_type n); + void xref:#unordered_multiset_reserve[reserve](size_type n); + }; +} // Equality Comparisons -template< - typename Value, - typename Mapped, - typename Hash, - typename Pred, - typename Alloc> -bool operator==(unordered_multiset const& x, - unordered_multiset const& y); +template + bool xref:#unordered_multiset_operator[operator++==++](const unordered_multiset& x, + const unordered_multiset& y); -template< - typename Value, - typename Mapped, - typename Hash, - typename Pred, - typename Alloc> -bool operator!=(unordered_multiset const& x, - unordered_multiset const& y); +template + bool xref:#unordered_multiset_operator_2[operator!=](const unordered_multiset& x, + const unordered_multiset& y); // swap -template -void swap(unordered_multiset& x, - unordered_multiset& y); +template + void xref:#unordered_multiset_swap_2[swap](unordered_multiset& x, + unordered_multiset& y) + noexcept(noexcept(x.swap(y))); ----- --- @@ -273,21 +198,21 @@ void swap(unordered_multiset& x, [cols="1,1"] |=== -|_Value_ -|`Value` must be https://en.cppreference.com/w/cpp/named_req/Erasable[Erasable^] from the container (i.e. `allocator_traits` can destroy it). +|_Key_ +|`Key` must be https://en.cppreference.com/w/cpp/named_req/Erasable[Erasable^] from the container (i.e. `allocator_traits` can destroy it). |_Hash_ -|A unary function object type that acts a hash function for a `Value`. It takes a single argument of type `Value` and returns a value of type `std::size_t`. +|A unary function object type that acts a hash function for a `Key`. It takes a single argument of type `Key` and returns a value of type `std::size_t`. |_Pred_ -|A binary function object that implements an equivalence relation on values of type `Value`. A binary function object that induces an equivalence relation on values of type `Value`. It takes two arguments of type `Value` and returns a value of type bool. +|A binary function object that implements an equivalence relation on values of type `Key`. A binary function object that induces an equivalence relation on values of type `Key`. It takes two arguments of type `Key` and returns a value of type bool. -|_Alloc_ +|_Allocator_ |An allocator whose value type is the same as the container's value type. |=== -The elements are organized into buckets. Keys with the same hash code are stored in the same bucket. +The elements are organized into buckets. Keys with the same hash code are stored in the same bucket and elements with equivalent keys are stored next to each other. The number of buckets can be automatically increased by a call to insert, or as the result of calling rehash. @@ -390,15 +315,6 @@ See node_handle_set for details. --- -[source,c++,subs=+quotes] ----- -typedef _implementation-defined_ insert_return_type; ----- - -Structure returned by inserting node_type. - ---- - === Constructors ==== Default Constructor @@ -410,39 +326,59 @@ Constructs an empty container using `hasher()` as the hash function, `key_equal()` as the key equality predicate, `allocator_type()` as the allocator and a maximum load factor of `1.0`. -Postconditions:: `size() == 0` -Requires:: If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. +[horizontal] +Postconditions:;; `size() == 0` +Requires:;; If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. --- ==== Bucket Count Constructor ```c++ explicit unordered_multiset(size_type n, - hasher const& hf = hasher(), - key_equal const& eq = key_equal(), - allocator_type const& a = allocator_type()); + const hasher& hf = hasher(), + const key_equal& eql = key_equal(), + const allocator_type& a = allocator_type()); ``` Constructs an empty container with at least `n` buckets, using `hf` as the hash -function, `eq` as the key equality predicate, `a` as the allocator and a maximum +function, `eql` as the key equality predicate, `a` as the allocator and a maximum load factor of `1.0`. -Postconditions:: `size() == 0` +[horizontal] +Postconditions:;; `size() == 0` +Requires:;; If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. -Requires:: If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. +--- + +==== Iterator Range Constructor +[source,c++,subs="+quotes"] +---- +template + unordered_multiset(InputIterator f, InputIterator l, + size_type n = _implementation-defined_, + const hasher& hf = hasher(), + const key_equal& eql = key_equal(), + const allocator_type& a = allocator_type()); +---- + +Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `eql` as the key equality predicate, `a` as the allocator and a maximum load factor of `1.0` and inserts the elements from `[f, l)` into it. + +[horizontal] +Requires:;; If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. --- ==== Copy Constructor ```c++ -unordered_multiset(unordered_multiset const& other); +unordered_multiset(const unordered_multiset& other); ``` The copy constructor. Copies the contained elements, hash function, predicate, maximum load factor and allocator. If `Allocator::select_on_container_copy_construction` exists and has the right signature, the allocator will be constructed from its result. -Requires:: `value_type` is copy constructible +[horizontal] +Requires:;; `value_type` is copy constructible --- @@ -453,16 +389,18 @@ unordered_multiset(unordered_multiset&& other); The move constructor. -Notes:: This is implemented using Boost.Move. - -Requires:: `value_type` is move-constructible. On compilers without rvalue reference support the emulation does not support moving without calling `boost::move` if `value_type` is not copyable. +[horizontal] +Notes:;; This is implemented using Boost.Move. +Requires:;; `value_type` is move-constructible. + ++ +On compilers without rvalue reference support the emulation does not support moving without calling `boost::move` if `value_type` is not copyable. So, for example, you can't return the container from a function. --- ==== Allocator Constructor ```c++ -explicit unordered_multiset(Allocator const& a); +explicit unordered_multiset(const Allocator& a); ``` Constructs an empty container, using allocator `a`. @@ -471,7 +409,7 @@ Constructs an empty container, using allocator `a`. ==== Copy Constructor with Allocator ```c++ -unordered_multiset(unordered_multiset const& other, Allocator const& a); +unordered_multiset(const unordered_multiset& other, const Allocator& a); ``` Constructs an container, copying ``other``'s contained elements, hash function, predicate, maximum load factor, but using allocator `a`. @@ -480,102 +418,86 @@ Constructs an container, copying ``other``'s contained elements, hash function, ==== Move Constructor with Allocator ```c++ -unordered_multiset(unordered_multiset&& other, Allocator const& a); +unordered_multiset(unordered_multiset&& other, const Allocator& a); ``` Construct a container moving ``other``'s contained elements, and having the hash function, predicate and maximum load factor, but using allocate `a`. -Notes:: This is implemented using Boost.Move. -Requires:: `value_type` is move insertable. +[horizontal] +Notes:;; This is implemented using Boost.Move. +Requires:;; `value_type` is move insertable. + +--- + +==== Initializer List Constructor +[source,c++,subs="+quotes"] +---- +unordered_multiset(initializer_list il, + size_type n = _implementation-defined_, + const hasher& hf = hasher(), + const key_equal& eql = key_equal(), + const allocator_type& a = allocator_type()); +---- + +Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `eql` as the key equality predicate, `a` as the allocator and a maximum load factor of `1.0` and inserts the elements from `il` into it. + +[horizontal] +Requires:;; If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. --- ==== Bucket Count Constructor with Allocator ```c++ -unordered_multiset(size_type n, allocator_type const& a); +unordered_multiset(size_type n, const allocator_type& a); ``` Constructs an empty container with at least `n` buckets, using `hf` as the hash function, the default hash function and key equality predicate, `a` as the allocator and a maximum load factor of `1.0`. -Postconditions:: `size() == 0` -Requires:: `hasher` and `key_equal` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. +[horizontal] +Postconditions:;; `size() == 0` +Requires:;; `hasher` and `key_equal` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. --- ==== Bucket Count Constructor with Hasher and Allocator ```c++ -unordered_multiset(size_type n, hasher const& hf, allocator_type const& a); +unordered_multiset(size_type n, const hasher& hf, const allocator_type& a); ``` Constructs an empty container with at least `n` buckets, using `hf` as the hash function, the default key equality predicate, `a` as the allocator and a maximum load factor of `1.0`. -Postconditions:: `size() == 0` -Requires:: `key_equal` needs to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. - ---- - -==== Initializer List Constructor -[source,c++,subs="quotes,macros"] ----- -unordered_multiset(initializer_list++<++value_type++>++ il, - size_type n = _implementation-defined_, - hasher const& hf = hasher(), - key_equal const& eq = key_equal(), - allocator_type const& a = allocator_type()); ----- - -Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `eq` as the key equality predicate, `a` as the allocator and a maximum load factor of `1.0` and inserts the elements from `il` into it. - -Requires:: If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. - ---- - -==== Iterator Range Constructor -[source,c++,subs="quotes,macros"] ----- -template++<++typename InputIterator++>++ -unordered_multiset(InputIterator f, - InputIterator l, - size_type n = _implementation-defined_, - hasher const& hf = hasher(), - key_equal const& eq = key_equal(), - allocator_type const& a = allocator_type()); ----- - -Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `eq` as the key equality predicate, `a` as the allocator and a maximum load factor of `1.0` and inserts the elements from `[f, l)` into it. - -Requires:: If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. +[horizontal] +Postconditions:;; `size() == 0` +Requires:;; `key_equal` needs to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. --- ==== Iterator Range Constructor with Bucket Count and Allocator -[source,c++,subs="quotes,macros"] +[source,c++,subs="+quotes"] ---- -template++<++typename InputIterator++>++ -unordered_multiset(InputIterator f, - InputIterator l, - size_type n, - allocator_type const& a); +template + unordered_multiset(InputIterator f, InputIterator l, size_type n, const allocator_type& a); ---- Constructs an empty container with at least `n` buckets, using `a` as the allocator, with the default hash function and key equality predicate and a maximum load factor of `1.0` and inserts the elements from `[f, l)` into it. -Requires:: `hasher`, `key_equal` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. +[horizontal] +Requires:;; `hasher`, `key_equal` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. + +--- ==== Iterator Range Constructor with Bucket Count and Hasher -[source,c++,subs="quotes,macros"] +[source,c++,subs="+quotes"] ---- -template++<++typename InputIterator++>++ -unordered_multiset(InputIterator f, - InputIterator l, - size_type n, - hasher const& hf, - allocator_type const& a); +template + unordered_multiset(InputIterator f, InputIterator l, size_type n, const hasher& hf, + const allocator_type& a); ---- Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `a` as the allocator, with the default key equality predicate and a maximum load factor of `1.0` and inserts the elements from `[f, l)` into it. -Requires:: `key_equal` needs to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. +[horizontal] +Requires:;; `key_equal` needs to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. --- @@ -584,7 +506,9 @@ Requires:: `key_equal` needs to be https://en.cppreference.com/w/cpp/named_req/D ```c++ ~unordered_multiset(); ``` -Note:: The destructor is applied to every element, and all memory is deallocated + +[horizontal] +Note:;; The destructor is applied to every element, and all memory is deallocated --- @@ -593,28 +517,32 @@ Note:: The destructor is applied to every element, and all memory is deallocated ==== Copy Assignment ```c++ -unordered_multiset& operator=(unordered_multiset const& other); +unordered_multiset& operator=(const unordered_multiset& other); ``` The assignment operator. Copies the contained elements, hash function, predicate and maximum load factor but not the allocator. If `Alloc::propagate_on_container_copy_assignment` exists and `Alloc::propagate_on_container_copy_assignment::value` is `true`, the allocator is overwritten, if not the copied elements are created using the existing allocator. -Requires:: `value_type` is copy constructible +[horizontal] +Requires:;; `value_type` is copy constructible --- ==== Move Assignment ```c++ -unordered_multiset& operator=(unordered_multiset&& other); +unordered_multiset& operator=(unordered_multiset&& other) + noexcept(boost::allocator_traits::is_always_equal::value && + boost::is_nothrow_move_assignable_v && + boost::is_nothrow_move_assignable_v); ``` The move assignment operator. If `Alloc::propagate_on_container_move_assignment` exists and `Alloc::propagate_on_container_move_assignment::value` is `true`, the allocator is overwritten, if not the moved elements are created using the existing allocator. -Notes:: On compilers without rvalue references, this is emulated using Boost.Move. Note that on some compilers the copy assignment operator may be used in some circumstances. - -Requires:: `value_type` is move constructible. +[horizontal] +Notes:;; On compilers without rvalue references, this is emulated using Boost.Move. Note that on some compilers the copy assignment operator may be used in some circumstances. +Requires:;; `value_type` is move constructible. --- @@ -625,37 +553,8 @@ unordered_multiset& operator=(initializer_list il); Assign from values in initializer list. All existing elements are either overwritten by the new elements or destroyed. -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^] into the container and https://en.cppreference.com/w/cpp/named_req/CopyAssignable[CopyAssignable^]. - -=== Size and Capacity - -==== empty - -```c++ -bool empty() const; -``` - -Returns:: `size() == 0` - ---- - -==== size - -```c++ -size_type size() const; -``` - -Returns:: `std::distance(begin(), end())` - ---- - -==== max_size - -```c++ -size_type max_size() const; -``` - -Returns:: `size()` of the largest possible container. +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^] into the container and https://en.cppreference.com/w/cpp/named_req/CopyAssignable[CopyAssignable^]. --- @@ -663,38 +562,78 @@ Returns:: `size()` of the largest possible container. ==== begin ```c++ -iterator begin(); -const_iterator begin() const; +iterator begin() noexcept; +const_iterator begin() const noexcept; ``` -Returns:: An iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container. +[horizontal] +Returns:;; An iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container. --- ==== end ```c++ -iterator end(); -const_iterator end() const; +iterator end() noexcept; +const_iterator end() const noexcept; ``` -Returns:: An iterator which refers to the past-the-end value for the container. +[horizontal] +Returns:;; An iterator which refers to the past-the-end value for the container. --- ==== cbegin ```c++ -const_iterator cbegin() const; +const_iterator cbegin() const noexcept; ``` -Returns:: A `const_iterator` referring to the first element of the container, or if the container is empty the past-the-end value for the container. + +[horizontal] +Returns:;; A `const_iterator` referring to the first element of the container, or if the container is empty the past-the-end value for the container. --- ==== cend ```c++ -const_iterator cend() const; +const_iterator cend() const noexcept; ``` -Returns:: A `const_iterator` which refers to the past-the-end value for the container. +[horizontal] +Returns:;; A `const_iterator` which refers to the past-the-end value for the container. + +--- + +=== Size and Capacity + +==== empty + +```c++ +bool empty() const noexcept; +``` + +[horizontal] +Returns:;; `size() == 0` + +--- + +==== size + +```c++ +size_type size() const noexcept; +``` + +[horizontal] +Returns:;; `std::distance(begin(), end())` + +--- + +==== max_size + +```c++ +size_type max_size() const noexcept; +``` + +[horizontal] +Returns:;; `size()` of the largest possible container. --- @@ -702,123 +641,102 @@ Returns:: A `const_iterator` which refers to the past-the-end value for the cont ==== emplace ```c++ -template -iterator -emplace(Args&&... args); +template iterator emplace(Args&&... args); ``` Inserts an object, constructed with the arguments args, in the container. -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `args`. - -Returns:: An iterator pointing to the inserted element. - -Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. -Pointers and references to elements are never invalidated. -If the compiler doesn't support variadic template arguments or rvalue references, this is emulated for up to `10` arguments, with no support for rvalue references or move semantics. +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `args`. +Returns:;; An iterator pointing to the inserted element. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. + ++ +If the compiler doesn't support variadic template arguments or rvalue references, this is emulated for up to `10` arguments, with no support for rvalue references or move semantics. + ++ Since existing `std::pair` implementations don't support `std::piecewise_construct` this emulates it, but using `boost::unordered::piecewise_construct`. --- ==== emplace_hint ```c++ -template -iterator -emplace_hint(const_iterator hint, Args&&... args); +template iterator emplace_hint(const_iterator position, Args&&... args); ``` Inserts an object, constructed with the arguments args, in the container. `hint` is a suggestion to where the element should be inserted. -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `args`. - -Returns:: An iterator pointing to the inserted element. - -Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. -Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. -Pointers and references to elements are never invalidated. -If the compiler doesn't support variadic template arguments or rvalue references, this is emulated for up to 10 arguments, with no support for rvalue references or move semantics. +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `args`. +Returns:;; An iterator pointing to the inserted element. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. + ++ +Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. + ++ +If the compiler doesn't support variadic template arguments or rvalue references, this is emulated for up to 10 arguments, with no support for rvalue references or move semantics. + ++ Since existing `std::pair` implementations don't support `std::piecewise_construct` this emulates it, but using `boost::unordered::piecewise_construct`. --- ==== Copy Insert ```c++ -iterator -insert(value_type const& obj); +iterator insert(const value_type& obj); ``` Inserts `obj` in the container. -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^]. - -Returns:: An iterator pointing to the inserted element. - -Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^]. +Returns:;; An iterator pointing to the inserted element. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. --- ==== Move Insert ```c++ -iterator -insert(value_type&& obj); +iterator insert(value_type&& obj); ``` Inserts `obj` in the container. -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/MoveInsertable[MoveInsertable^]. - -Returns:: An iterator pointing to the inserted element. - -Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. - ---- - -==== Insert with `node_handle` -```c++ -iterator -insert(node_type&& nh); -``` - -If `nh` is empty, has no effect. - -Otherwise inserts the element owned by `nh`. - -Requires:: `nh` is empty or `nh.get_allocator()` is equal to the container's allocator. - -Returns:: If `nh` was empty, returns `end()`. Otherwise returns an iterator pointing to the newly inserted element. - -Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. In C++17 this can be used to insert a node extracted from a compatible `unordered_set`, but that is not supported yet. +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/MoveInsertable[MoveInsertable^]. +Returns:;; An iterator pointing to the inserted element. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. --- ==== Copy Insert with Hint ```c++ -iterator insert(const_iterator hint, value_type const& obj); +iterator insert(const_iterator hint, const value_type& obj); ``` Inserts `obj` in the container. `hint` is a suggestion to where the element should be inserted. -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^]. - -Returns:: An iterator pointing to the inserted element. - -Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^]. +Returns:;; An iterator pointing to the inserted element. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. + ++ +Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. --- @@ -831,13 +749,111 @@ Inserts `obj` in the container. `hint` is a suggestion to where the element should be inserted. -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/MoveInsertable[MoveInsertable^]. +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/MoveInsertable[MoveInsertable^]. +Returns:;; An iterator pointing to the inserted element. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. + ++ +Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. -Returns:: An iterator pointing to the inserted element. +--- -Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +==== Insert Iterator Range +```c++ +template void insert(InputIterator first, InputIterator last); +``` -Notes:: The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. +Inserts a range of elements into the container. + +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `*first`. +Throws:;; When inserting a single element, if an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. + +--- + +==== Insert Initializer List +```c++ +void insert(initializer_list il); +``` + +Inserts a range of elements into the container. Elements are inserted if and only if there is no element in the container with an equivalent key. + +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `*first`. +Throws:;; When inserting a single element, if an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. + +--- + +==== Extract by Iterator +```c++ +node_type extract(const_iterator position); +``` + +Removes the element pointed to by `position`. + +[horizontal] +Returns:;; A `node_type` owning the element. +Notes:;; In C++17 a node extracted using this method can be inserted into a compatible `unordered_set`, but that is not supported yet. + +--- + +==== Extract by Value +```c++ +node_type extract(const key_type& k); +``` + +Removes an element with key equivalent to `k`. + +[horizontal] +Returns:;; A `node_type` owning the element if found, otherwise an empty `node_type`. +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. +Notes:;; In C++17 a node extracted using this method can be inserted into a compatible `unordered_set`, but that is not supported yet. + +--- + +==== Transparent Extract by Value +```c++ +template node_type extract(K&& k); +``` + +Removes an element with key equivalent to `k`. + +This overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs and neither `iterator` nor `const_iterator` are implicitly convertible from `K`. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. + +[horizontal] +Returns:;; A `node_type` owning the element if found, otherwise an empty `node_type`. +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`.[horizontal] +Notes:;; In C++17 a node extracted using this method can be inserted into a compatible `unordered_set`, but that is not supported yet. + +--- + +==== Insert with `node_handle` +```c++ +iterator insert(node_type&& nh); +``` + +If `nh` is empty, has no effect. + +Otherwise inserts the element owned by `nh`. + +[horizontal] +Requires:;; `nh` is empty or `nh.get_allocator()` is equal to the container's allocator. +Returns:;; If `nh` was empty, returns `end()`. + ++ +Otherwise returns an iterator pointing to the newly inserted element. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. In C++17 this can be used to insert a node extracted from a compatible `unordered_set`, but that is not supported yet. --- @@ -852,106 +868,63 @@ Otherwise inserts the element owned by `nh`. `hint` is a suggestion to where the element should be inserted. -Requires:: `nh` is empty or `nh.get_allocator()` is equal to the container's allocator. - -Returns:: If `nh` was empty, returns `end()`. - +[horizontal] +Requires:;; `nh` is empty or `nh.get_allocator()` is equal to the container's allocator. +Returns:;; If `nh` was empty, returns `end()`. + ++ Otherwise returns an iterator pointing to the newly inserted element. - -Throws:: If an exception is thrown by an operation other than a call to hasher the function has no effect. - -Notes:: The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. In C++17 this can be used to insert a node extracted from a compatible `unordered_set`, but that is not supported yet. +Throws:;; If an exception is thrown by an operation other than a call to hasher the function has no effect. +Notes:;; The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. + ++ +Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. + ++ +In C++17 this can be used to insert a node extracted from a compatible `unordered_set`, but that is not supported yet. --- -==== Insert Iterator Range -```c++ -template -void insert(InputIterator first, InputIterator last); -``` - -Inserts a range of elements into the container. - -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `*first`. - -Throws:: When inserting a single element, if an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. - ---- - -==== Insert Initializer List -```c++ -void insert(initializer_list il); -``` - -Inserts a range of elements into the container. Elements are inserted if and only if there is no element in the container with an equivalent key. - -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `*first`. - -Throws:: When inserting a single element, if an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. - ---- - -==== Extract by Iterator -```c++ -node_type extract(const_iterator position); -``` - -Removes the element pointed to by `position`. - -Returns:: A `node_type` owning the element. - -Notes:: In C++17 a node extracted using this method can be inserted into a compatible `unordered_set`, but that is not supported yet. - ---- - -==== Transparent Extract by Value -```c++ -template -node_type extract(K&& k); -``` - -Removes an element with key equivalent to `k`. - -This overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs and neither `iterator` nor `const_iterator` are implicitly convertible from `K`. The library assumes that `Hash` is callable with both `K` and `Value` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Value` type. - -Returns:: A `node_type` owning the element if found, otherwise an empty `node_type`. - -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. - -Notes:: In C++17 a node extracted using this method can be inserted into a compatible `unordered_set`, but that is not supported yet. - ---- - -==== Extract by Value -```c++ -node_type extract(key_type const& k); -``` - -Removes an element with key equivalent to `k`. - -Returns:: A `node_type` owning the element if found, otherwise an empty `node_type`. - -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. - -Notes:: In C++17 a node extracted using this method can be inserted into a compatible `unordered_set`, but that is not supported yet. - ==== Erase by Position ```c++ +iterator erase(iterator position); iterator erase(const_iterator position); ``` Erase the element pointed to by `position`. -Returns:: The iterator following `position` before the erasure. +[horizontal] +Returns:;; The iterator following `position` before the erasure. +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. +Notes:;; In older versions this could be inefficient because it had to search through several buckets to find the position of the returned iterator. The data structure has been changed so that this is no longer the case, and the alternative erase methods have been deprecated. -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. +--- -Notes:: In older versions this could be inefficient because it had to search through several buckets to find the position of the returned iterator. The data structure has been changed so that this is no longer the case, and the alternative erase methods have been deprecated. +==== Erase by Value +```c++ +size_type erase(const key_type& k); +``` + +Erase all elements with key equivalent to `k`. + +[horizontal] +Returns:;; The number of elements erased. +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. + +--- + +==== Transparent Erase by Value +```c++ +template size_type erase(K&& x); +``` + +Erase all elements with key equivalent to `k`. + +This overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs and neither `iterator` nor `const_iterator` are implicitly convertible from `K`. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. + +[horizontal] +Returns:;; The number of elements erased. +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. --- @@ -963,38 +936,11 @@ iterator erase(const_iterator first, const_iterator last); Erases the elements in the range from `first` to `last`. -Returns:: The iterator following the erased elements - i.e. `last`. - -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations. - ---- - -==== Transparent Erase by Value -```c++ -template -size_type erase(K&& k); -``` - -Erase all elements with key equivalent to `k`. - -This overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs and neither `iterator` nor `const_iterator` are implicitly convertible from `K`. The library assumes that `Hash` is callable with both `K` and `Value` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Value` type. - -Returns:: The number of elements erased. - -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. - ---- - -==== Erase by Value -```c++ -size_type erase(key_type const& k); -``` - -Erase all elements with key equivalent to `k`. - -Returns:: The number of elements erased. - -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. +[horizontal] +Returns:;; The iterator following the erased elements - i.e. `last`. +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. + ++ +In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations. --- @@ -1005,9 +951,11 @@ void quick_erase(const_iterator position); Erase the element pointed to by `position`. -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations. - -Notes:: This method was implemented because returning an iterator to the next element from erase was expensive, but the container has been redesigned so that is no longer the case. So this method is now deprecated. +[horizontal] +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. + ++ +In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations. +Notes:;; This method was implemented because returning an iterator to the next element from erase was expensive, but the container has been redesigned so that is no longer the case. So this method is now deprecated. --- @@ -1018,57 +966,64 @@ void erase_return_void(const_iterator position); Erase the element pointed to by `position`. -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations. - -Notes:: This method was implemented because returning an iterator to the next element from erase was expensive, but the container has been redesigned so that is no longer the case. So this method is now deprecated. - ---- - -==== clear -```c++ -void clear(); -``` - -Erases all elements in the container. - -Postconditions:: `size() == 0` - -Throws:: Never throws an exception. +[horizontal] +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. + ++ +In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations. +Notes:;; This method was implemented because returning an iterator to the next element from erase was expensive, but the container has been redesigned so that is no longer the case. So this method is now deprecated. --- ==== swap ```c++ -void swap(unordered_multiset& other); +void swap(unordered_multiset&) + noexcept(boost::allocator_traits::is_always_equal::value && + boost::is_nothrow_swappable_v && + boost::is_nothrow_swappable_v); ``` Swaps the contents of the container with the parameter. If `Allocator::propagate_on_container_swap` is declared and `Allocator::propagate_on_container_swap::value` is `true` then the containers' allocators are swapped. Otherwise, swapping with unequal allocators results in undefined behavior. -Throws:: Doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of `key_equal` or `hasher`. +[horizontal] +Throws:;; Doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of `key_equal` or `hasher`. +Notes:;; The exception specifications aren't quite the same as the C++11 standard, as the equality predicate and hash function are swapped using their copy constructors. -Notes:: The exception specifications aren't quite the same as the C++11 standard, as the equality predicate and hash function are swapped using their copy constructors. +--- + +==== clear +```c++ +void clear() noexcept; +``` + +Erases all elements in the container. + +[horizontal] +Postconditions:;; `size() == 0` +Throws:;; Never throws an exception. --- ==== merge ```c++ -template -void merge(unordered_multiset& source); +template + void merge(unordered_multiset& source); ``` -Notes:: Does not support merging with a compatible `unordered_set` yet. +[horizontal] +Notes:;; Does not support merging with a compatible `unordered_set` yet. --- ==== merge (rvalue reference) ```c++ -template -void merge(unordered_multiset&& source); +template + void merge(unordered_multiset&& source); ``` -Notes:: Does not support merging with a compatible `unordered_set` yet. +[horizontal] +Notes:;; Does not support merging with a compatible `unordered_set` yet. --- @@ -1076,23 +1031,29 @@ Notes:: Does not support merging with a compatible `unordered_set` yet. ==== get_allocator ``` -allocator_type get_allocator() const; +allocator_type get_allocator() const noexcept; ``` +--- + ==== hash_function ``` hasher hash_function() const; ``` -Returns:: The container's hash function. +[horizontal] +Returns:;; The container's hash function. --- +==== key_eq + ``` key_equal key_eq() const; ``` -Returns:: The container's key equality predicate +[horizontal] +Returns:;; The container's key equality predicate --- @@ -1100,90 +1061,67 @@ Returns:: The container's key equality predicate ==== find ```c++ -iterator find(key_type const& k); -const_iterator find(key_type const& k) const; - -template -iterator -find(K const& k); - -template -const_iterator -find(K const& k) const; - -template< - typename CompatibleValue, - typename CompatibleHash, - typename CompatiblePredicate> -iterator -find(CompatibleValue const& k, - CompatibleHash const& hash, - CompatiblePredicate const& eq); - -template< - typename CompatibleValue, - typename CompatibleHash, - typename CompatiblePredicate> -const_iterator -find(CompatibleValue const& k, - CompatibleHash const& hash, - CompatiblePredicate const& eq) const; - +iterator find(const key_type& k); +const_iterator find(const key_type& k) const; +template + iterator find(const K& k); +template + const_iterator find(const K& k) const; +template + iterator find(CompatibleKey const&, CompatibleHash const&, + CompatiblePredicate const&); +template + const_iterator find(CompatibleKey const&, CompatibleHash const&, + CompatiblePredicate const&) const; ``` -Returns:: An iterator pointing to an element with key equivalent to `k`, or `b.end()` if no such element exists. - -Notes:: The templated overloads containing `CompatibleValue`, `CompatibleHash` and `CompatiblePredicate` are non-standard extensions which allow you to use a compatible hash function and equality predicate for a key of a different type in order to avoid an expensive type cast. In general, its use is not encouraged and instead the `K` member function templates should be used. + -The `template ` overloads only participate in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Value` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Value` type. - ---- - -==== contains -```c++ -template -bool contains(K const& key); -bool contains(key_type const& key) const; -``` - -Returns:: A boolean indicating whether or not there is an element with key equal to `key` in the container - -Notes:: The `template ` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Value` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Value` type. +[horizontal] +Returns:;; An iterator pointing to an element with key equivalent to `k`, or `b.end()` if no such element exists. +Notes:;; The templated overloads containing `CompatibleKey`, `CompatibleHash` and `CompatiblePredicate` are non-standard extensions which allow you to use a compatible hash function and equality predicate for a key of a different type in order to avoid an expensive type cast. In general, its use is not encouraged and instead the `K` member function templates should be used. + ++ +The `template ` overloads only participate in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. --- ==== count ```c++ -template -size_type count(K const& k) const; -size_type count(key_type const& k) const; +size_type count(const key_type& k) const; +template + size_type count(const K& k) const; ``` -Returns:: The number of elements with key equivalent to `k`. +[horizontal] +Returns:;; The number of elements with key equivalent to `k`. +Notes:;; The `template ` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. -Notes:: The `template ` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Value` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Value` type. +--- + +==== contains +```c++ +bool contains(const key_type& k) const; +template + bool contains(const K& k) const; +``` + +[horizontal] +Returns:;; A boolean indicating whether or not there is an element with key equal to `key` in the container +Notes:;; The `template ` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. --- ==== equal_range ```c++ -std::pair -equal_range(key_type const& k); - -std::pair -equal_range(key_type const& k) const; - -template -std::pair -equal_range(K const& k); - -template -std::pair -equal_range(K const& k) const; +std::pair equal_range(const key_type& k); +std::pair equal_range(const key_type& k) const; +template + std::pair equal_range(const K& k); +template + std::pair equal_range(const K& k) const; ``` -Returns:: A range containing all elements with key equivalent to `k`. If the container doesn't contain any such elements, returns `std::make_pair(b.end(), b.end())`. - -Notes:: The `template ` overloads only participate in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Value` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Value` type. +[horizontal] +Returns:;; A range containing all elements with key equivalent to `k`. If the container doesn't contain any such elements, returns `std::make_pair(b.end(), b.end())`. +Notes:;; The `template ` overloads only participate in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. --- @@ -1191,19 +1129,21 @@ Notes:: The `template ` overloads only participate in overload resol ==== bucket_count ```c++ -size_type bucket_count() const; +size_type bucket_count() const noexcept; ``` -Returns:: The number of buckets. +[horizontal] +Returns:;; The number of buckets. --- ==== max_bucket_count ```c++ -size_type max_bucket_count() const; +size_type max_bucket_count() const noexcept; ``` -Returns:: An upper bound on the number of buckets. +[horizontal] +Returns:;; An upper bound on the number of buckets. --- @@ -1212,20 +1152,20 @@ Returns:: An upper bound on the number of buckets. size_type bucket_size(size_type n) const; ``` -Requires:: `n < bucket_count()` - -Returns:: The number of elements in bucket `n`. +[horizontal] +Requires:;; `n < bucket_count()` +Returns:;; The number of elements in bucket `n`. --- ==== bucket ```c++ -size_type bucket(key_type const& k) const; +size_type bucket(const key_type& k) const; ``` -Returns:: The index of the bucket which would contain an element with key `k`. - -Postconditions:: The return value is less than `bucket_count()`. +[horizontal] +Returns:;; The index of the bucket which would contain an element with key `k`. +Postconditions:;; The return value is less than `bucket_count()`. --- @@ -1236,9 +1176,9 @@ local_iterator begin(size_type n); const_local_iterator begin(size_type n) const; ``` -Requires:: `n` shall be in the range `[0, bucket_count())`. - -Returns:: A local iterator pointing the first element in the bucket with index `n`. +[horizontal] +Requires:;; `n` shall be in the range `[0, bucket_count())`. +Returns:;; A local iterator pointing the first element in the bucket with index `n`. --- @@ -1248,9 +1188,9 @@ local_iterator end(size_type n); const_local_iterator end(size_type n) const; ``` -Requires:: `n` shall be in the range `[0, bucket_count())`. - -Returns:: A local iterator pointing the 'one past the end' element in the bucket with index `n`. +[horizontal] +Requires:;; `n` shall be in the range `[0, bucket_count())`. +Returns:;; A local iterator pointing the 'one past the end' element in the bucket with index `n`. --- @@ -1259,9 +1199,9 @@ Returns:: A local iterator pointing the 'one past the end' element in the bucket const_local_iterator cbegin(size_type n) const; ``` -Requires:: `n` shall be in the range `[0, bucket_count())`. - -Returns:: A constant local iterator pointing the first element in the bucket with index `n`. +[horizontal] +Requires:;; `n` shall be in the range `[0, bucket_count())`. +Returns:;; A constant local iterator pointing the first element in the bucket with index `n`. --- @@ -1270,9 +1210,9 @@ Returns:: A constant local iterator pointing the first element in the bucket wit const_local_iterator cend(size_type n) const; ``` -Requires:: `n` shall be in the range `[0, bucket_count())`. - -Returns:: A constant local iterator pointing the 'one past the end' element in the bucket with index `n`. +[horizontal] +Requires:;; `n` shall be in the range `[0, bucket_count())`. +Returns:;; A constant local iterator pointing the 'one past the end' element in the bucket with index `n`. --- @@ -1280,20 +1220,22 @@ Returns:: A constant local iterator pointing the 'one past the end' element in t ==== load_factor ```c++ -float load_factor() const; +float load_factor() const noexcept; ``` -Returns:: The average number of elements per bucket. +[horizontal] +Returns:;; The average number of elements per bucket. --- ==== max_load_factor ```c++ -float max_load_factor() const; +float max_load_factor() const noexcept; ``` -Returns:: Returns the current maximum load factor. +[horizontal] +Returns:;; Returns the current maximum load factor. --- @@ -1302,11 +1244,11 @@ Returns:: Returns the current maximum load factor. void max_load_factor(float z); ``` -Effects:: Changes the container's maximum load factor, using `z` as a hint. +[horizontal] +Effects:;; Changes the container's maximum load factor, using `z` as a hint. --- - ==== rehash ```c++ void rehash(size_type n); @@ -1316,7 +1258,8 @@ Changes the number of buckets so that there at least `n` buckets, and so that th Invalidates iterators, and changes the order of elements. Pointers and references to elements are not invalidated. -Throws:: The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function. +[horizontal] +Throws:;; The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function. --- @@ -1327,60 +1270,60 @@ void reserve(size_type n); Invalidates iterators, and changes the order of elements. Pointers and references to elements are not invalidated. -Throws:: The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function. +[horizontal] +Throws:;; The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function. + +--- === Equality Comparisons ==== operator== ```c++ -template< - typename Value, - typename Mapped, - typename Hash, - typename Pred, - typename Alloc> -bool operator==(unordered_multiset const& x, - unordered_multiset const& y); +template + bool operator==(const unordered_multiset& x, + const unordered_multiset& y); ``` Return `true` if `x.size() == y.size()` and for every element in `x`, there is an element in `y` with the same key, with an equal value (using `operator==` to compare the value types). -Notes:: The behavior of this function was changed to match the C++11 standard in Boost 1.48. Behavior is undefined if the two containers don't have equivalent equality predicates. +[horizontal] +Notes:;; The behavior of this function was changed to match the C++11 standard in Boost 1.48. + ++ +Behavior is undefined if the two containers don't have equivalent equality predicates. --- ==== operator!= ```c++ -template< - typename Value, - typename Mapped, - typename Hash, - typename Pred, - typename Alloc> -bool operator!=(unordered_multiset const& x, - unordered_multiset const& y); +template + bool operator!=(const unordered_multiset& x, + const unordered_multiset& y); ``` Return `false` if `x.size() == y.size()` and for every element in `x`, there is an element in `y` with the same key, with an equal value (using `operator==` to compare the value types). -Notes:: The behavior of this function was changed to match the C++11 standard in Boost 1.48. Behavior is undefined if the two containers don't have equivalent equality predicates. +[horizontal] +Notes:;; The behavior of this function was changed to match the C++11 standard in Boost 1.48. + ++ +Behavior is undefined if the two containers don't have equivalent equality predicates. + +--- === Swap ```c++ -template -void swap(unordered_multiset& x, - unordered_multiset& y); +template + void swap(unordered_multiset& x, + unordered_multiset& y) + noexcept(noexcept(x.swap(y))); ``` Swaps the contents of `x` and `y`. If `Allocator::propagate_on_container_swap` is declared and `Allocator::propagate_on_container_swap::value` is `true` then the containers' allocators are swapped. Otherwise, swapping with unequal allocators results in undefined behavior. -Effects:: `x.swap(y)` - -Throws:: Doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of `key_equal` or `hasher`. - -Notes:: The exception specifications aren't quite the same as the C++11 standard, as the equality predicate and hash function are swapped using their copy constructors. +[horizontal] +Effects:;; `x.swap(y)` +Throws:;; Doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of `key_equal` or `hasher`. +Notes:;; The exception specifications aren't quite the same as the C++11 standard, as the equality predicate and hash function are swapped using their copy constructors. diff --git a/doc/unordered/unordered_set.adoc b/doc/unordered/unordered_set.adoc index d453eb7d..e976b97a 100644 --- a/doc/unordered/unordered_set.adoc +++ b/doc/unordered/unordered_set.adoc @@ -7,261 +7,187 @@ === Synopsis -[source,c++,subs=+quotes] +[listing,subs="+macros,+quotes"] ----- // #include -template< - typename Value, - typename Hash = boost::hash, - typename Pred = std::equal_to, - typename Alloc = std::allocator> > -class unordered_set { -public: - // types - typedef Value key_type; - typedef Value value_type; - typedef Hash hasher; - typedef Pred key_equal; - typedef Alloc allocator_type; - typedef typename allocator_type::pointer pointer; - typedef typename allocator_type::const_pointer const_pointer; - typedef value_type& reference; - typedef value_type const& const_reference; - typedef _implementation-defined_ size_type; - typedef _implementation-defined_ difference_type; - typedef _implementation-defined_ iterator; - typedef _implementation-defined_ const_iterator; - typedef _implementation-defined_ local_iterator; - typedef _implementation-defined_ const_local_iterator; - typedef _implementation-defined_ node_type; - typedef _implementation-defined_ insert_return_type; +namespace boost { + template, + class Pred = std::equal_to, + class Allocator = std::allocator> + class unordered_set { + public: + // types + using key_type = Key; + using value_type = Key; + using hasher = Hash; + using key_equal = Pred; + using allocator_type = Allocator; + using pointer = typename boost::allocator_traits::pointer; + using const_pointer = typename boost::allocator_traits::const_pointer; + using reference = value_type&; + using const_reference = const value_type&; + using size_type = _implementation-defined_; + using difference_type = _implementation-defined_; - // construct/copy/destruct - unordered_set(); + using iterator = _implementation-defined_; + using const_iterator = _implementation-defined_; + using local_iterator = _implementation-defined_; + using const_local_iterator = _implementation-defined_; + using node_type = _implementation-defined_; + using insert_return_type = _implementation-defined_; - explicit unordered_set(size_type n, - hasher const& hf = hasher(), - key_equal const& eq = key_equal(), - allocator_type const& a = allocator_type()); + // construct/copy/destroy + xref:#unordered_set_default_constructor[unordered_set](); + explicit xref:#unordered_set_bucket_count_constructor[unordered_set](size_type n, + const hasher& hf = hasher(), + const key_equal& eql = key_equal(), + const allocator_type& a = allocator_type()); + template + xref:#unordered_set_iterator_range_constructor[unordered_set](InputIterator f, InputIterator l, + size_type n = _implementation-defined_, + const hasher& hf = hasher(), + const key_equal& eql = key_equal(), + const allocator_type& a = allocator_type()); + xref:#unordered_set_copy_constructor[unordered_set](const unordered_set& other); + xref:#unordered_set_move_constructor[unordered_set](unordered_set&& other); + explicit xref:#unordered_set_allocator_constructor[unordered_set](const Allocator& a); + xref:#unordered_set_copy_constructor_with_allocator[unordered_set](const unordered_set& other, const Allocator& a); + xref:#unordered_set_move_constructor_with_allocator[unordered_set](unordered_set&& other, const Allocator& a); + xref:#unordered_set_initializer_list_constructor[unordered_set](initializer_list il, + size_type n = _implementation-defined_, + const hasher& hf = hasher(), + const key_equal& eql = key_equal(), + const allocator_type& a = allocator_type()); + xref:#unordered_set_bucket_count_constructor_with_allocator[unordered_set](size_type n, const allocator_type& a); + xref:#unordered_set_bucket_count_constructor_with_hasher_and_allocator[unordered_set](size_type n, const hasher& hf, const allocator_type& a); + template + xref:#unordered_set_iterator_range_constructor_with_bucket_count_and_allocator[unordered_set](InputIterator f, InputIterator l, size_type n, const allocator_type& a); + template + xref:#unordered_set_iterator_range_constructor_with_bucket_count_and_hasher[unordered_set](InputIterator f, InputIterator l, size_type n, const hasher& hf, + const allocator_type& a); + xref:#unordered_set_destructor[~unordered_set](); + unordered_set& xref:#unordered_set_copy_assignment[operator++=++](const unordered_set& other); + unordered_set& xref:#unordered_set_move_assignment[operator++=++](unordered_set&& other) + noexcept(boost::allocator_traits::is_always_equal::value && + boost::is_nothrow_move_assignable_v && + boost::is_nothrow_move_assignable_v); + unordered_set& xref:#unordered_set_initializer_list_assignment[operator++=++](initializer_list il); + allocator_type xref:#unordered_set_get_allocator[get_allocator]() const noexcept; - unordered_set(unordered_set const& other); - unordered_set(unordered_set&& other); + // iterators + iterator xref:#unordered_set_begin[begin]() noexcept; + const_iterator xref:#unordered_set_begin[begin]() const noexcept; + iterator xref:#unordered_set_end[end]() noexcept; + const_iterator xref:#unordered_set_end[end]() const noexcept; + const_iterator xref:#unordered_set_cbegin[cbegin]() const noexcept; + const_iterator xref:#unordered_set_cend[cend]() const noexcept; - explicit unordered_set(Allocator const& a); - unordered_set(unordered_set const& other, Allocator const& a); - unordered_set(unordered_set&& other, Allocator const& a); + // capacity + bool xref:#unordered_set_empty[empty]() const noexcept; + size_type xref:#unordered_set_size[size]() const noexcept; + size_type xref:#unordered_set_max_size[max_size]() const noexcept; - unordered_set(size_type n, allocator_type const& a); - unordered_set(size_type n, hasher const& hf, allocator_type const& a); + // modifiers + template std::pair xref:#unordered_set_emplace[emplace](Args&&... args); + template iterator xref:#unordered_set_emplace_hint[emplace_hint](const_iterator position, Args&&... args); + std::pair xref:#unordered_set_copy_insert[insert](const value_type& obj); + std::pair xref:#unordered_set_move_insert[insert](value_type&& obj); + iterator xref:#unordered_set_copy_insert_with_hint[insert](const_iterator hint, const value_type& obj); + iterator xref:#unordered_set_move_insert_with_hint[insert](const_iterator hint, value_type&& obj); + template void xref:#unordered_set_insert_iterator_range[insert](InputIterator first, InputIterator last); + void xref:#unordered_set_insert_initializer_list[insert](initializer_list); - unordered_set(initializer_list il, - size_type n = _implementation-defined_, - hasher const& hf = hasher(), - key_equal const& eq = key_equal(), - allocator_type const& a = allocator_type()); + node_type xref:#unordered_set_extract_by_iterator[extract](const_iterator position); + node_type xref:#unordered_set_extract_by_value[extract](const key_type& k); + template node_type xref:#unordered_set_transparent_extract_by_value[extract](K&& k); + insert_return_type xref:#unordered_set_insert_with_node_handle[insert](node_type&& nh); + iterator xref:#unordered_set_insert_with_hint_and_node_handle[insert](const_iterator hint, node_type&& nh); - template - unordered_set(InputIterator f, - InputIterator l, - size_type n = _implementation-defined_, - hasher const& hf = hasher(), - key_equal const& eq = key_equal(), - allocator_type const& a = allocator_type()); + iterator xref:#unordered_set_erase_by_position[erase](iterator position); + iterator xref:#unordered_set_erase_by_position[erase](const_iterator position); + size_type xref:#unordered_set_erase_by_value[erase](const key_type& k); + template size_type xref:#unordered_set_transparent_erase_by_value[erase](K&& k); + iterator xref:#unordered_set_erase_range[erase](const_iterator first, const_iterator last); + void xref:#unordered_set_quick_erase[quick_erase](const_iterator position); + void xref:#unordered_set_erase_return_void[erase_return_void](const_iterator position); + void xref:#unordered_set_swap[swap](unordered_set& other) + noexcept(boost::allocator_traits::is_always_equal::value && + boost::is_nothrow_swappable_v && + boost::is_nothrow_swappable_v); + void xref:#unordered_set_clear[clear]() noexcept; - template - unordered_set(InputIterator f, - InputIterator l, - size_type n, - allocator_type const& a); + template + void xref:#unordered_set_merge[merge](unordered_set& source); + template + void xref:#unordered_set_merge_rvalue_reference[merge](unordered_set&& source); - template - unordered_set(InputIterator f, - InputIterator l, - size_type n, - hasher const& hf, - allocator_type const& a); + // observers + hasher xref:#unordered_set_hash_function[hash_function]() const; + key_equal xref:#unordered_set_key_eq[key_eq]() const; - ~unordered_set(); + // set operations + iterator xref:#unordered_set_find[find](const key_type& k); + const_iterator xref:#unordered_set_find[find](const key_type& k) const; + template + iterator xref:#unordered_set_find[find](const K& k); + template + const_iterator xref:#unordered_set_find[find](const K& k) const; + template + iterator xref:#unordered_set_find[find](CompatibleKey const& k, CompatibleHash const& hash, + CompatiblePredicate const& eq); + template + const_iterator xref:#unordered_set_find[find](CompatibleKey const& k, CompatibleHash const& hash, + CompatiblePredicate const& eq) const; + size_type xref:#unordered_set_count[count](const key_type& k) const; + template + size_type xref:#unordered_set_count[count](const K& k) const; + bool xref:#unordered_set_contains[contains](const key_type& k) const; + template + bool xref:#unordered_set_contains[contains](const K& k) const; + pair xref:#unordered_set_equal_range[equal_range](const key_type& k); + pair xref:#unordered_set_equal_range[equal_range](const key_type& k) const; + template + pair xref:#unordered_set_equal_range[equal_range](const K& k); + template + pair xref:#unordered_set_equal_range[equal_range](const K& k) const; - unordered_set& operator=(unordered_set const& other); - unordered_set& operator=(unordered_set&& other); - unordered_set& operator=(initializer_list il); + // bucket interface + size_type xref:#unordered_set_bucket_count[bucket_count]() const noexcept; + size_type xref:#unordered_set_max_bucket_count[max_bucket_count]() const noexcept; + size_type xref:#unordered_set_bucket_size[bucket_size](size_type n) const; + size_type xref:#unordered_set_bucket[bucket](const key_type& k) const; + local_iterator xref:#unordered_set_begin_2[begin](size_type n); + const_local_iterator xref:#unordered_set_begin_2[begin](size_type n) const; + local_iterator xref:#unordered_set_end_2[end](size_type n); + const_local_iterator xref:#unordered_set_end_2[end](size_type n) const; + const_local_iterator xref:#unordered_set_cbegin_2[cbegin](size_type n) const; + const_local_iterator xref:#unordered_set_cend_2[cend](size_type n) const; - // size and capacity - bool empty() const; - size_type size() const; - size_type max_size() const; - - // iterators - iterator begin(); - const_iterator begin() const; - - iterator end(); - const_iterator end() const; - - const_iterator cbegin() const; - const_iterator cend() const; - - // modifiers - template - std::pair - emplace(Args&&... args); - - template - iterator - emplace_hint(const_iterator hint, Args&&... args); - - std::pair - insert(value_type const& obj); - - std::pair - insert(value_type&& obj); - - insert_return_type insert(node_type&& nh); - - iterator insert(const_iterator hint, value_type const& obj); - iterator insert(const_iterator hint, value_type&& obj); - iterator insert(const_iterator hint, node_type&& nh); - - template - void insert(InputIterator first, InputIterator last); - - void insert(initializer_list il); - - node_type extract(const_iterator position); - node_type extract(key_type const& k); - - template - node_type extract(K&& k); - - iterator erase(const_iterator position); - iterator erase(const_iterator first, const_iterator last); - size_type erase(key_type const& k); - - template - size_type erase(K&& k); - - void quick_erase(const_iterator position); - void erase_return_void(const_iterator position); - - void clear(); - void swap(unordered_set& other); - - template - void merge(unordered_set& source); - - template - void merge(unordered_set&& source); - - // observers - allocator_type get_allocator() const; - hasher hash_function() const; - key_equal key_eq() const; - - // lookup - iterator find(key_type const& k); - const_iterator find(key_type const& k) const; - - template - iterator - find(K const& k); - - template - const_iterator - find(K const& k) const; - - template< - typename CompatibleValue, - typename CompatibleHash, - typename CompatiblePredicate> - iterator - find(CompatibleValue const& k, - CompatibleHash const& hash, - CompatiblePredicate const&) eq; - - template< - typename CompatibleValue, - typename CompatibleHash, - typename CompatiblePredicate> - const_iterator - find(CompatibleValue const& k, - CompatibleHash const& hash, - CompatiblePredicate const& eq) const; - - bool contains(key_type const& key) const; - - template - bool contains(K const& key); - - size_type count(key_type const& k) const; - - template - size_type count(K const& k) const; - - std::pair - equal_range(key_type const& k); - - std::pair - equal_range(key_type const& k) const; - - template - std::pair - equal_range(K const& k); - - template - std::pair - equal_range(K const& k) const; - - // bucket interface - size_type bucket_count() const; - size_type max_bucket_count() const; - size_type bucket_size(size_type n) const; - size_type bucket(key_type const& k) const; - - local_iterator begin(size_type n); - const_local_iterator begin(size_type n) const; - - local_iterator end(size_type n); - const_local_iterator end(size_type n) const; - - const_local_iterator cbegin(size_type n) const; - const_local_iterator cend(size_type n) const; - - // hash policy - float load_factor() const; - float max_load_factor() const; - - void max_load_factor(float z); - - void rehash(size_type n); - void reserve(size_type n); -}; + // hash policy + float xref:#unordered_set_load_factor[load_factor]() const noexcept; + float xref:#unordered_set_max_load_factor[max_load_factor]() const noexcept; + void xref:#unordered_set_set_max_load_factor[max_load_factor](float z); + void xref:#unordered_set_rehash[rehash](size_type n); + void xref:#unordered_set_reserve[reserve](size_type n); + }; +} // Equality Comparisons -template< - typename Value, - typename Mapped, - typename Hash, - typename Pred, - typename Alloc> -bool operator==(unordered_set const& x, - unordered_set const& y); +template + bool xref:#unordered_set_operator[operator++==++](const unordered_set& x, + const unordered_set& y); -template< - typename Value, - typename Mapped, - typename Hash, - typename Pred, - typename Alloc> -bool operator!=(unordered_set const& x, - unordered_set const& y); +template + bool xref:#unordered_set_operator_2[operator!=](const unordered_set& x, + const unordered_set& y); // swap -template -void swap(unordered_set& x, - unordered_set& y); +template + void xref:#unordered_set_swap_2[swap](unordered_set& x, + unordered_set& y) + noexcept(noexcept(x.swap(y))); ----- --- @@ -273,16 +199,16 @@ void swap(unordered_set& x, [cols="1,1"] |=== -|_Value_ -|`Value` must be https://en.cppreference.com/w/cpp/named_req/Erasable[Erasable^] from the container (i.e. `allocator_traits` can destroy it). +|_Key_ +|`Key` must be https://en.cppreference.com/w/cpp/named_req/Erasable[Erasable^] from the container (i.e. `allocator_traits` can destroy it). |_Hash_ -|A unary function object type that acts a hash function for a `Value`. It takes a single argument of type `Value` and returns a value of type `std::size_t`. +|A unary function object type that acts a hash function for a `Key`. It takes a single argument of type `Key` and returns a value of type `std::size_t`. |_Pred_ -|A binary function object that implements an equivalence relation on values of type `Value`. A binary function object that induces an equivalence relation on values of type `Value`. It takes two arguments of type `Value` and returns a value of type bool. +|A binary function object that implements an equivalence relation on values of type `Key`. A binary function object that induces an equivalence relation on values of type `Key`. It takes two arguments of type `Key` and returns a value of type bool. -|_Alloc_ +|_Allocator_ |An allocator whose value type is the same as the container's value type. |=== @@ -411,39 +337,59 @@ Constructs an empty container using `hasher()` as the hash function, `key_equal()` as the key equality predicate, `allocator_type()` as the allocator and a maximum load factor of `1.0`. -Postconditions:: `size() == 0` -Requires:: If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. +[horizontal] +Postconditions:;; `size() == 0` +Requires:;; If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. --- ==== Bucket Count Constructor ```c++ explicit unordered_set(size_type n, - hasher const& hf = hasher(), - key_equal const& eq = key_equal(), - allocator_type const& a = allocator_type()); + const hasher& hf = hasher(), + const key_equal& eql = key_equal(), + const allocator_type& a = allocator_type()); ``` Constructs an empty container with at least `n` buckets, using `hf` as the hash -function, `eq` as the key equality predicate, `a` as the allocator and a maximum +function, `eql` as the key equality predicate, `a` as the allocator and a maximum load factor of `1.0`. -Postconditions:: `size() == 0` +[horizontal] +Postconditions:;; `size() == 0` +Requires:;; If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. -Requires:: If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. +--- + +==== Iterator Range Constructor +[source,c++,subs="+quotes"] +---- +template + unordered_set(InputIterator f, InputIterator l, + size_type n = _implementation-defined_, + const hasher& hf = hasher(), + const key_equal& eql = key_equal(), + const allocator_type& a = allocator_type()); +---- + +Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `eql` as the key equality predicate, `a` as the allocator and a maximum load factor of `1.0` and inserts the elements from `[f, l)` into it. + +[horizontal] +Requires:;; If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. --- ==== Copy Constructor ```c++ -unordered_set(unordered_set const& other); +unordered_set(const unordered_set& other); ``` The copy constructor. Copies the contained elements, hash function, predicate, maximum load factor and allocator. If `Allocator::select_on_container_copy_construction` exists and has the right signature, the allocator will be constructed from its result. -Requires:: `value_type` is copy constructible +[horizontal] +Requires:;; `value_type` is copy constructible --- @@ -454,16 +400,18 @@ unordered_set(unordered_set&& other); The move constructor. -Notes:: This is implemented using Boost.Move. - -Requires:: `value_type` is move-constructible. On compilers without rvalue reference support the emulation does not support moving without calling `boost::move` if `value_type` is not copyable. +[horizontal] +Notes:;; This is implemented using Boost.Move. +Requires:;; `value_type` is move-constructible. + ++ +On compilers without rvalue reference support the emulation does not support moving without calling `boost::move` if `value_type` is not copyable. So, for example, you can't return the container from a function. --- ==== Allocator Constructor ```c++ -explicit unordered_set(Allocator const& a); +explicit unordered_set(const Allocator& a); ``` Constructs an empty container, using allocator `a`. @@ -472,7 +420,7 @@ Constructs an empty container, using allocator `a`. ==== Copy Constructor with Allocator ```c++ -unordered_set(unordered_set const& other, Allocator const& a); +unordered_set(const unordered_set& other, const Allocator& a); ``` Constructs an container, copying ``other``'s contained elements, hash function, predicate, maximum load factor, but using allocator `a`. @@ -481,102 +429,86 @@ Constructs an container, copying ``other``'s contained elements, hash function, ==== Move Constructor with Allocator ```c++ -unordered_set(unordered_set&& other, Allocator const& a); +unordered_set(unordered_set&& other, const Allocator& a); ``` Construct a container moving ``other``'s contained elements, and having the hash function, predicate and maximum load factor, but using allocate `a`. -Notes:: This is implemented using Boost.Move. -Requires:: `value_type` is move insertable. +[horizontal] +Notes:;; This is implemented using Boost.Move. +Requires:;; `value_type` is move insertable. + +--- + +==== Initializer List Constructor +[source,c++,subs="+quotes"] +---- +unordered_set(initializer_list il, + size_type n = _implementation-defined_, + const hasher& hf = hasher(), + const key_equal& eql = key_equal(), + const allocator_type& a = allocator_type()); +---- + +Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `eql` as the key equality predicate, `a` as the allocator and a maximum load factor of `1.0` and inserts the elements from `il` into it. + +[horizontal] +Requires:;; If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. --- ==== Bucket Count Constructor with Allocator ```c++ -unordered_set(size_type n, allocator_type const& a); +unordered_set(size_type n, const allocator_type& a); ``` Constructs an empty container with at least `n` buckets, using `hf` as the hash function, the default hash function and key equality predicate, `a` as the allocator and a maximum load factor of `1.0`. -Postconditions:: `size() == 0` -Requires:: `hasher` and `key_equal` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. +[horizontal] +Postconditions:;; `size() == 0` +Requires:;; `hasher` and `key_equal` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. --- ==== Bucket Count Constructor with Hasher and Allocator ```c++ -unordered_set(size_type n, hasher const& hf, allocator_type const& a); +unordered_set(size_type n, const hasher& hf, const allocator_type& a); ``` Constructs an empty container with at least `n` buckets, using `hf` as the hash function, the default key equality predicate, `a` as the allocator and a maximum load factor of `1.0`. -Postconditions:: `size() == 0` -Requires:: `key_equal` needs to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. - ---- - -==== Initializer List Constructor -[source,c++,subs="quotes,macros"] ----- -unordered_set(initializer_list++<++value_type++>++ il, - size_type n = _implementation-defined_, - hasher const& hf = hasher(), - key_equal const& eq = key_equal(), - allocator_type const& a = allocator_type()); ----- - -Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `eq` as the key equality predicate, `a` as the allocator and a maximum load factor of `1.0` and inserts the elements from `il` into it. - -Requires:: If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. - ---- - -==== Iterator Range Constructor -[source,c++,subs="quotes,macros"] ----- -template++<++typename InputIterator++>++ -unordered_set(InputIterator f, - InputIterator l, - size_type n = _implementation-defined_, - hasher const& hf = hasher(), - key_equal const& eq = key_equal(), - allocator_type const& a = allocator_type()); ----- - -Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `eq` as the key equality predicate, `a` as the allocator and a maximum load factor of `1.0` and inserts the elements from `[f, l)` into it. - -Requires:: If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. +[horizontal] +Postconditions:;; `size() == 0` +Requires:;; `key_equal` needs to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. --- ==== Iterator Range Constructor with Bucket Count and Allocator -[source,c++,subs="quotes,macros"] +[source,c++,subs="+quotes"] ---- -template++<++typename InputIterator++>++ -unordered_set(InputIterator f, - InputIterator l, - size_type n, - allocator_type const& a); +template + unordered_set(InputIterator f, InputIterator l, size_type n, const allocator_type& a); ---- Constructs an empty container with at least `n` buckets, using `a` as the allocator, with the default hash function and key equality predicate and a maximum load factor of `1.0` and inserts the elements from `[f, l)` into it. -Requires:: `hasher`, `key_equal` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. +[horizontal] +Requires:;; `hasher`, `key_equal` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. + +--- ==== Iterator Range Constructor with Bucket Count and Hasher -[source,c++,subs="quotes,macros"] +[source,c++,subs="+quotes"] ---- -template++<++typename InputIterator++>++ -unordered_set(InputIterator f, - InputIterator l, - size_type n, - hasher const& hf, - allocator_type const& a); +template + unordered_set(InputIterator f, InputIterator l, size_type n, const hasher& hf, + const allocator_type& a); ---- Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `a` as the allocator, with the default key equality predicate and a maximum load factor of `1.0` and inserts the elements from `[f, l)` into it. -Requires:: `key_equal` needs to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. +[horizontal] +Requires:;; `key_equal` needs to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^]. --- @@ -585,7 +517,9 @@ Requires:: `key_equal` needs to be https://en.cppreference.com/w/cpp/named_req/D ```c++ ~unordered_set(); ``` -Note:: The destructor is applied to every element, and all memory is deallocated + +[horizontal] +Note:;; The destructor is applied to every element, and all memory is deallocated --- @@ -594,28 +528,32 @@ Note:: The destructor is applied to every element, and all memory is deallocated ==== Copy Assignment ```c++ -unordered_set& operator=(unordered_set const& other); +unordered_set& operator=(const unordered_set& other); ``` The assignment operator. Copies the contained elements, hash function, predicate and maximum load factor but not the allocator. If `Alloc::propagate_on_container_copy_assignment` exists and `Alloc::propagate_on_container_copy_assignment::value` is `true`, the allocator is overwritten, if not the copied elements are created using the existing allocator. -Requires:: `value_type` is copy constructible +[horizontal] +Requires:;; `value_type` is copy constructible --- ==== Move Assignment ```c++ -unordered_set& operator=(unordered_set&& other); +unordered_set& operator=(unordered_set&& other) + noexcept(boost::allocator_traits::is_always_equal::value && + boost::is_nothrow_move_assignable_v && + boost::is_nothrow_move_assignable_v); ``` The move assignment operator. If `Alloc::propagate_on_container_move_assignment` exists and `Alloc::propagate_on_container_move_assignment::value` is `true`, the allocator is overwritten, if not the moved elements are created using the existing allocator. -Notes:: On compilers without rvalue references, this is emulated using Boost.Move. Note that on some compilers the copy assignment operator may be used in some circumstances. - -Requires:: `value_type` is move constructible. +[horizontal] +Notes:;; On compilers without rvalue references, this is emulated using Boost.Move. Note that on some compilers the copy assignment operator may be used in some circumstances. +Requires:;; `value_type` is move constructible. --- @@ -626,37 +564,8 @@ unordered_set& operator=(initializer_list il); Assign from values in initializer list. All existing elements are either overwritten by the new elements or destroyed. -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^] into the container and https://en.cppreference.com/w/cpp/named_req/CopyAssignable[CopyAssignable^]. - -=== Size and Capacity - -==== empty - -```c++ -bool empty() const; -``` - -Returns:: `size() == 0` - ---- - -==== size - -```c++ -size_type size() const; -``` - -Returns:: `std::distance(begin(), end())` - ---- - -==== max_size - -```c++ -size_type max_size() const; -``` - -Returns:: `size()` of the largest possible container. +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^] into the container and https://en.cppreference.com/w/cpp/named_req/CopyAssignable[CopyAssignable^]. --- @@ -664,38 +573,78 @@ Returns:: `size()` of the largest possible container. ==== begin ```c++ -iterator begin(); -const_iterator begin() const; +iterator begin() noexcept; +const_iterator begin() const noexcept; ``` -Returns:: An iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container. +[horizontal] +Returns:;; An iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container. --- ==== end ```c++ -iterator end(); -const_iterator end() const; +iterator end() noexcept; +const_iterator end() const noexcept; ``` -Returns:: An iterator which refers to the past-the-end value for the container. +[horizontal] +Returns:;; An iterator which refers to the past-the-end value for the container. --- ==== cbegin ```c++ -const_iterator cbegin() const; +const_iterator cbegin() const noexcept; ``` -Returns:: A `const_iterator` referring to the first element of the container, or if the container is empty the past-the-end value for the container. + +[horizontal] +Returns:;; A `const_iterator` referring to the first element of the container, or if the container is empty the past-the-end value for the container. --- ==== cend ```c++ -const_iterator cend() const; +const_iterator cend() const noexcept; ``` -Returns:: A `const_iterator` which refers to the past-the-end value for the container. +[horizontal] +Returns:;; A `const_iterator` which refers to the past-the-end value for the container. + +--- + +=== Size and Capacity + +==== empty + +```c++ +bool empty() const noexcept; +``` + +[horizontal] +Returns:;; `size() == 0` + +--- + +==== size + +```c++ +size_type size() const noexcept; +``` + +[horizontal] +Returns:;; `std::distance(begin(), end())` + +--- + +==== max_size + +```c++ +size_type max_size() const noexcept; +``` + +[horizontal] +Returns:;; `size()` of the largest possible container. --- @@ -703,123 +652,107 @@ Returns:: A `const_iterator` which refers to the past-the-end value for the cont ==== emplace ```c++ -template -std::pair -emplace(Args&&... args); +template pair emplace(Args&&... args); ``` Inserts an object, constructed with the arguments `args`, in the container if and only if there is no element in the container with an equivalent value. -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `args`. - -Returns:: The bool component of the return type is true if an insert took place. + +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `args`. +Returns:;; The bool component of the return type is true if an insert took place. + ++ If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent value. - -Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. -Pointers and references to elements are never invalidated. -If the compiler doesn't support variadic template arguments or rvalue references, this is emulated for up to `10` arguments, with no support for rvalue references or move semantics. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. + ++ +If the compiler doesn't support variadic template arguments or rvalue references, this is emulated for up to `10` arguments, with no support for rvalue references or move semantics. + ++ Since existing `std::pair` implementations don't support `std::piecewise_construct` this emulates it, but using `boost::unordered::piecewise_construct`. --- ==== emplace_hint ```c++ -template -iterator -emplace_hint(const_iterator hint, Args&&... args); +template iterator emplace_hint(const_iterator position, Args&&... args); ``` Inserts an object, constructed with the arguments `args`, in the container if and only if there is no element in the container with an equivalent value. -`hint` is a suggestion to where the element should be inserted. +`position` is a suggestion to where the element should be inserted. -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `args`. - -Returns:: If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. - -Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. -Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. -Pointers and references to elements are never invalidated. -If the compiler doesn't support variadic template arguments or rvalue references, this is emulated for up to 10 arguments, with no support for rvalue references or move semantics. +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `args`. +Returns:;; If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. + ++ +Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. + ++ +If the compiler doesn't support variadic template arguments or rvalue references, this is emulated for up to 10 arguments, with no support for rvalue references or move semantics. + ++ Since existing `std::pair` implementations don't support `std::piecewise_construct` this emulates it, but using `boost::unordered::piecewise_construct`. --- ==== Copy Insert ```c++ -std::pair -insert(value_type const& obj); +std::pair insert(const value_type& obj); ``` Inserts `obj` in the container if and only if there is no element in the container with an equivalent key. -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^]. - -Returns:: The bool component of the return type is true if an insert took place. If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. - -Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^]. +Returns:;; The bool component of the return type is true if an insert took place. + ++ +If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. --- ==== Move Insert ```c++ -std::pair -insert(value_type&& obj); +std::pair insert(value_type&& obj); ``` Inserts `obj` in the container if and only if there is no element in the container with an equivalent key. -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/MoveInsertable[MoveInsertable^]. - -Returns:: The bool component of the return type is true if an insert took place. If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. - -Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. - ---- - -==== Insert with `node_handle` -```c++ -insert_return_type -insert(node_type&& nh); -``` - -If `nh` is empty, has no effect. - -Otherwise inserts the element owned by `nh` if and only if there is no element in the container with an equivalent key. - -Requires:: `nh` is empty or `nh.get_allocator()` is equal to the container's allocator. - -Returns:: If `nh` was empty, returns an `insert_return_type` with: `inserted` equal to `false`, `position` equal to `end()` and `node` empty. Otherwise if there was already an element with an equivalent key, returns an `insert_return_type` with: `inserted` equal to `false`, `position` pointing to a matching element and `node` contains the node from `nh`. Otherwise if the insertion succeeded, returns an `insert_return_type` with: `inserted` equal to `true`, `position` pointing to the newly inserted element and `node` empty. - -Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. In C++17 this can be used to insert a node extracted from a compatible `unordered_multiset`, but that is not supported yet. +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/MoveInsertable[MoveInsertable^]. +Returns:;; The bool component of the return type is true if an insert took place. + ++ +If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. --- ==== Copy Insert with Hint ```c++ -iterator insert(const_iterator hint, value_type const& obj); +iterator insert(const_iterator hint, const value_type& obj); ``` Inserts `obj` in the container if and only if there is no element in the container with an equivalent key. `hint` is a suggestion to where the element should be inserted. -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^]. - -Returns:: If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. - -Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^]. +Returns:;; If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. + ++ +Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. --- @@ -832,13 +765,115 @@ Inserts `obj` in the container if and only if there is no element in the contain `hint` is a suggestion to where the element should be inserted. -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/MoveInsertable[MoveInsertable^]. +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/MoveInsertable[MoveInsertable^]. +Returns:;; If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. + ++ +Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. -Returns:: If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. +--- -Throws:: If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +==== Insert Iterator Range +```c++ +template void insert(InputIterator first, InputIterator last); +``` -Notes:: The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. +Inserts a range of elements into the container. Elements are inserted if and only if there is no element in the container with an equivalent key. + +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `*first`. +Throws:;; When inserting a single element, if an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. + +--- + +==== Insert Initializer List +```c++ +void insert(initializer_list); +``` + +Inserts a range of elements into the container. Elements are inserted if and only if there is no element in the container with an equivalent key. + +[horizontal] +Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `*first`. +Throws:;; When inserting a single element, if an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. + +--- + +==== Extract by Iterator +```c++ +node_type extract(const_iterator position); +``` + +Removes the element pointed to by `position`. + +[horizontal] +Returns:;; A `node_type` owning the element. +Notes:;; In C++17 a node extracted using this method can be inserted into a compatible `unordered_multiset`, but that is not supported yet. + +--- + +==== Extract by Value +```c++ +node_type extract(const key_type& k); +``` + +Removes an element with key equivalent to `k`. + +[horizontal] +Returns:;; A `node_type` owning the element if found, otherwise an empty `node_type`. +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. +Notes:;; In C++17 a node extracted using this method can be inserted into a compatible `unordered_multiset`, but that is not supported yet. + +--- + +==== Transparent Extract by Value +```c++ +template node_type extract(K&& k); +``` + +Removes an element with key equivalent to `k`. + +This overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs and neither `iterator` nor `const_iterator` are implicitly convertible from `K`. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. + +[horizontal] +Returns:;; A `node_type` owning the element if found, otherwise an empty `node_type`. +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. +Notes:;; In C++17 a node extracted using this method can be inserted into a compatible `unordered_multiset`, but that is not supported yet. + +--- + +==== Insert with `node_handle` +```c++ +insert_return_type insert(node_type&& nh); +``` + +If `nh` is empty, has no effect. + +Otherwise inserts the element owned by `nh` if and only if there is no element in the container with an equivalent key. + +[horizontal] +Requires:;; `nh` is empty or `nh.get_allocator()` is equal to the container's allocator. +Returns:;; If `nh` was empty, returns an `insert_return_type` with: `inserted` equal to `false`, `position` equal to `end()` and `node` empty. + ++ +Otherwise if there was already an element with an equivalent key, returns an `insert_return_type` with: `inserted` equal to `false`, `position` pointing to a matching element and `node` contains the node from `nh`. + ++ +Otherwise if the insertion succeeded, returns an `insert_return_type` with: `inserted` equal to `true`, `position` pointing to the newly inserted element and `node` empty. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. + ++ +In C++17 this can be used to insert a node extracted from a compatible `unordered_multiset`, but that is not supported yet. --- @@ -855,104 +890,65 @@ If there is already an element in the container with an equivalent key has no ef `hint` is a suggestion to where the element should be inserted. -Requires:: `nh` is empty or `nh.get_allocator()` is equal to the container's allocator. - -Returns:: If `nh` was empty returns `end()`. If there was already an element in the container with an equivalent key returns an iterator pointing to that. Otherwise returns an iterator pointing to the newly inserted element. - -Throws:: If an exception is thrown by an operation other than a call to hasher the function has no effect. - -Notes:: The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. In C++17 this can be used to insert a node extracted from a compatible `unordered_multiset`, but that is not supported yet. +[horizontal] +Requires:;; `nh` is empty or `nh.get_allocator()` is equal to the container's allocator. +Returns:;; If `nh` was empty returns `end()`. + ++ +If there was already an element in the container with an equivalent key returns an iterator pointing to that. + ++ +Otherwise returns an iterator pointing to the newly inserted element. +Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. +Notes:;; The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. + ++ +Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + ++ +Pointers and references to elements are never invalidated. + ++ +In C++17 this can be used to insert a node extracted from a compatible `unordered_multiset`, but that is not supported yet. --- -==== Insert Iterator Range -```c++ -template -void insert(InputIterator first, InputIterator last); -``` - -Inserts a range of elements into the container. Elements are inserted if and only if there is no element in the container with an equivalent key. - -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `*first`. - -Throws:: When inserting a single element, if an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. - ---- - -==== Insert Initializer List -```c++ -void insert(initializer_list il); -``` - -Inserts a range of elements into the container. Elements are inserted if and only if there is no element in the container with an equivalent key. - -Requires:: `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `*first`. - -Throws:: When inserting a single element, if an exception is thrown by an operation other than a call to `hasher` the function has no effect. - -Notes:: Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. Pointers and references to elements are never invalidated. - ---- - -==== Extract by Iterator -```c++ -node_type extract(const_iterator position); -``` - -Removes the element pointed to by `position`. - -Returns:: A `node_type` owning the element. - -Notes:: In C++17 a node extracted using this method can be inserted into a compatible `unordered_multiset`, but that is not supported yet. - ---- - -==== Transparent Extract by Value -```c++ -template -node_type extract(K&& k); -``` - -Removes an element with key equivalent to `k`. - -This overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs and neither `iterator` nor `const_iterator` are implicitly convertible from `K`. The library assumes that `Hash` is callable with both `K` and `Value` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Value` type. - -Returns:: A `node_type` owning the element if found, otherwise an empty `node_type`. - -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. - -Notes:: In C++17 a node extracted using this method can be inserted into a compatible `unordered_multiset`, but that is not supported yet. - ---- - -==== Extract by Value -```c++ -node_type extract(key_type const& k); -``` - -Removes an element with key equivalent to `k`. - -Returns:: A `node_type` owning the element if found, otherwise an empty `node_type`. - -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. - -Notes:: In C++17 a node extracted using this method can be inserted into a compatible `unordered_multiset`, but that is not supported yet. - ==== Erase by Position ```c++ +iterator erase(iterator position); iterator erase(const_iterator position); ``` Erase the element pointed to by `position`. -Returns:: The iterator following `position` before the erasure. +[horizontal] +Returns:;; The iterator following `position` before the erasure. +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. +Notes:;; In older versions this could be inefficient because it had to search through several buckets to find the position of the returned iterator. The data structure has been changed so that this is no longer the case, and the alternative erase methods have been deprecated. -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. +--- -Notes:: In older versions this could be inefficient because it had to search through several buckets to find the position of the returned iterator. The data structure has been changed so that this is no longer the case, and the alternative erase methods have been deprecated. +==== Erase by Value +```c++ +size_type erase(const key_type& k); +``` + +Erase all elements with key equivalent to `k`. + +[horizontal] +Returns:;; The number of elements erased. +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. + +--- + +==== Transparent Erase by Value +```c++ +template size_type erase(K&& k); +``` + +Erase all elements with key equivalent to `k`. + +This overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs and neither `iterator` nor `const_iterator` are implicitly convertible from `K`. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. + +[horizontal] +Returns:;; The number of elements erased. +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. --- @@ -964,38 +960,11 @@ iterator erase(const_iterator first, const_iterator last); Erases the elements in the range from `first` to `last`. -Returns:: The iterator following the erased elements - i.e. `last`. - -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations. - ---- - -==== Transparent Erase by Value -```c++ -template -size_type erase(K&& k); -``` - -Erase all elements with key equivalent to `k`. - -This overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs and neither `iterator` nor `const_iterator` are implicitly convertible from `K`. The library assumes that `Hash` is callable with both `K` and `Value` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Value` type. - -Returns:: The number of elements erased. - -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. - ---- - -==== Erase by Value -```c++ -size_type erase(key_type const& k); -``` - -Erase all elements with key equivalent to `k`. - -Returns:: The number of elements erased. - -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. +[horizontal] +Returns:;; The iterator following the erased elements - i.e. `last`. +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. + ++ +In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations. --- @@ -1006,9 +975,11 @@ void quick_erase(const_iterator position); Erase the element pointed to by `position`. -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations. - -Notes:: This method was implemented because returning an iterator to the next element from erase was expensive, but the container has been redesigned so that is no longer the case. So this method is now deprecated. +[horizontal] +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. + ++ +In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations. +Notes:;; This method was implemented because returning an iterator to the next element from erase was expensive, but the container has been redesigned so that is no longer the case. So this method is now deprecated. --- @@ -1019,57 +990,64 @@ void erase_return_void(const_iterator position); Erase the element pointed to by `position`. -Throws:: Only throws an exception if it is thrown by `hasher` or `key_equal`. In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations. - -Notes:: This method was implemented because returning an iterator to the next element from erase was expensive, but the container has been redesigned so that is no longer the case. So this method is now deprecated. - ---- - -==== clear -```c++ -void clear(); -``` - -Erases all elements in the container. - -Postconditions:: `size() == 0` - -Throws:: Never throws an exception. +[horizontal] +Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. + ++ +In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations. +Notes:;; This method was implemented because returning an iterator to the next element from erase was expensive, but the container has been redesigned so that is no longer the case. So this method is now deprecated. --- ==== swap ```c++ -void swap(unordered_set& other); +void swap(unordered_set& other) + noexcept(boost::allocator_traits::is_always_equal::value && + boost::is_nothrow_swappable_v && + boost::is_nothrow_swappable_v); ``` Swaps the contents of the container with the parameter. If `Allocator::propagate_on_container_swap` is declared and `Allocator::propagate_on_container_swap::value` is `true` then the containers' allocators are swapped. Otherwise, swapping with unequal allocators results in undefined behavior. -Throws:: Doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of `key_equal` or `hasher`. +[horizontal] +Throws:;; Doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of `key_equal` or `hasher`. +Notes:;; The exception specifications aren't quite the same as the C++11 standard, as the equality predicate and hash function are swapped using their copy constructors. -Notes:: The exception specifications aren't quite the same as the C++11 standard, as the equality predicate and hash function are swapped using their copy constructors. +--- + +==== clear +```c++ +void clear() noexcept; +``` + +Erases all elements in the container. + +[horizontal] +Postconditions:;; `size() == 0` +Throws:;; Never throws an exception. --- ==== merge ```c++ -template -void merge(unordered_set& source); +template + void merge(unordered_set& source); ``` -Notes:: Does not support merging with a compatible `unordered_multiset` yet. +[horizontal] +Notes:;; Does not support merging with a compatible `unordered_multiset` yet. --- ==== merge (rvalue reference) ```c++ -template -void merge(unordered_set&& source); +template + void merge(unordered_set&& source); ``` -Notes:: Does not support merging with a compatible `unordered_multiset` yet. +[horizontal] +Notes:;; Does not support merging with a compatible `unordered_multiset` yet. --- @@ -1080,20 +1058,26 @@ Notes:: Does not support merging with a compatible `unordered_multiset` yet. allocator_type get_allocator() const; ``` +--- + ==== hash_function ``` hasher hash_function() const; ``` -Returns:: The container's hash function. +[horizontal] +Returns:;; The container's hash function. --- +==== key_eq + ``` key_equal key_eq() const; ``` -Returns:: The container's key equality predicate +[horizontal] +Returns:;; The container's key equality predicate --- @@ -1101,90 +1085,67 @@ Returns:: The container's key equality predicate ==== find ```c++ -iterator find(key_type const& k); -const_iterator find(key_type const& k) const; - -template -iterator -find(K const& k); - -template -const_iterator -find(K const& k) const; - -template< - typename CompatibleValue, - typename CompatibleHash, - typename CompatiblePredicate> -iterator -find(CompatibleValue const& k, - CompatibleHash const& hash, - CompatiblePredicate const& eq); - -template< - typename CompatibleValue, - typename CompatibleHash, - typename CompatiblePredicate> -const_iterator -find(CompatibleValue const& k, - CompatibleHash const& hash, - CompatiblePredicate const& eq) const; - +iterator find(const key_type& k); +const_iterator find(const key_type& k) const; +template + iterator find(const K& k); +template + const_iterator find(const K& k) const; +template + iterator find(CompatibleKey const& k, CompatibleHash const& hash, + CompatiblePredicate const& eq); +template + const_iterator find(CompatibleKey const& k, CompatibleHash const& hash, + CompatiblePredicate const& eq) const; ``` -Returns:: An iterator pointing to an element with key equivalent to `k`, or `b.end()` if no such element exists. - -Notes:: The templated overloads containing `CompatibleValue`, `CompatibleHash` and `CompatiblePredicate` are non-standard extensions which allow you to use a compatible hash function and equality predicate for a key of a different type in order to avoid an expensive type cast. In general, its use is not encouraged and instead the `K` member function templates should be used. + -The `template ` overloads only participate in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Value` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Value` type. - ---- - -==== contains -```c++ -template -bool contains(K const& key); -bool contains(key_type const& key) const; -``` - -Returns:: A boolean indicating whether or not there is an element with key equal to `key` in the container - -Notes:: The `template ` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Value` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Value` type. +[horizontal] +Returns:;; An iterator pointing to an element with key equivalent to `k`, or `b.end()` if no such element exists. +Notes:;; The templated overloads containing `CompatibleKey`, `CompatibleHash` and `CompatiblePredicate` are non-standard extensions which allow you to use a compatible hash function and equality predicate for a key of a different type in order to avoid an expensive type cast. In general, its use is not encouraged and instead the `K` member function templates should be used. + ++ +The `template ` overloads only participate in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. --- ==== count ```c++ -template -size_type count(K const& k) const; -size_type count(key_type const& k) const; +size_type count(const key_type& k) const; +template + size_type count(const K& k) const; ``` -Returns:: The number of elements with key equivalent to `k`. +[horizontal] +Returns:;; The number of elements with key equivalent to `k`. +Notes:;; The `template ` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. -Notes:: The `template ` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Value` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Value` type. +--- + +==== contains +```c++ +bool contains(const key_type& k) const; +template + bool contains(const K& k) const; +``` + +[horizontal] +Returns:;; A boolean indicating whether or not there is an element with key equal to `key` in the container +Notes:;; The `template ` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. --- ==== equal_range ```c++ -std::pair -equal_range(key_type const& k); - -std::pair -equal_range(key_type const& k) const; - -template -std::pair -equal_range(K const& k); - -template -std::pair -equal_range(K const& k) const; +pair equal_range(const key_type& k); +pair equal_range(const key_type& k) const; +template + pair equal_range(const K& k); +template + pair equal_range(const K& k) const; ``` -Returns:: A range containing all elements with key equivalent to `k`. If the container doesn't contain any such elements, returns `std::make_pair(b.end(), b.end())`. - -Notes:: The `template ` overloads only participate in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Value` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Value` type. +[horizontal] +Returns:;; A range containing all elements with key equivalent to `k`. If the container doesn't contain any such elements, returns `std::make_pair(b.end(), b.end())`. +Notes:;; The `template ` overloads only participate in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type. --- @@ -1192,19 +1153,21 @@ Notes:: The `template ` overloads only participate in overload resol ==== bucket_count ```c++ -size_type bucket_count() const; +size_type bucket_count() const noexcept; ``` -Returns:: The number of buckets. +[horizontal] +Returns:;; The number of buckets. --- ==== max_bucket_count ```c++ -size_type max_bucket_count() const; +size_type max_bucket_count() const noexcept; ``` -Returns:: An upper bound on the number of buckets. +[horizontal] +Returns:;; An upper bound on the number of buckets. --- @@ -1213,20 +1176,20 @@ Returns:: An upper bound on the number of buckets. size_type bucket_size(size_type n) const; ``` -Requires:: `n < bucket_count()` - -Returns:: The number of elements in bucket `n`. +[horizontal] +Requires:;; `n < bucket_count()` +Returns:;; The number of elements in bucket `n`. --- ==== bucket ```c++ -size_type bucket(key_type const& k) const; +size_type bucket(const key_type& k) const; ``` -Returns:: The index of the bucket which would contain an element with key `k`. - -Postconditions:: The return value is less than `bucket_count()`. +[horizontal] +Returns:;; The index of the bucket which would contain an element with key `k`. +Postconditions:;; The return value is less than `bucket_count()`. --- @@ -1237,9 +1200,9 @@ local_iterator begin(size_type n); const_local_iterator begin(size_type n) const; ``` -Requires:: `n` shall be in the range `[0, bucket_count())`. - -Returns:: A local iterator pointing the first element in the bucket with index `n`. +[horizontal] +Requires:;; `n` shall be in the range `[0, bucket_count())`. +Returns:;; A local iterator pointing the first element in the bucket with index `n`. --- @@ -1249,9 +1212,9 @@ local_iterator end(size_type n); const_local_iterator end(size_type n) const; ``` -Requires:: `n` shall be in the range `[0, bucket_count())`. - -Returns:: A local iterator pointing the 'one past the end' element in the bucket with index `n`. +[horizontal] +Requires:;; `n` shall be in the range `[0, bucket_count())`. +Returns:;; A local iterator pointing the 'one past the end' element in the bucket with index `n`. --- @@ -1260,9 +1223,9 @@ Returns:: A local iterator pointing the 'one past the end' element in the bucket const_local_iterator cbegin(size_type n) const; ``` -Requires:: `n` shall be in the range `[0, bucket_count())`. - -Returns:: A constant local iterator pointing the first element in the bucket with index `n`. +[horizontal] +Requires:;; `n` shall be in the range `[0, bucket_count())`. +Returns:;; A constant local iterator pointing the first element in the bucket with index `n`. --- @@ -1271,9 +1234,9 @@ Returns:: A constant local iterator pointing the first element in the bucket wit const_local_iterator cend(size_type n) const; ``` -Requires:: `n` shall be in the range `[0, bucket_count())`. - -Returns:: A constant local iterator pointing the 'one past the end' element in the bucket with index `n`. +[horizontal] +Requires:;; `n` shall be in the range `[0, bucket_count())`. +Returns:;; A constant local iterator pointing the 'one past the end' element in the bucket with index `n`. --- @@ -1281,20 +1244,22 @@ Returns:: A constant local iterator pointing the 'one past the end' element in t ==== load_factor ```c++ -float load_factor() const; +float load_factor() const noexcept; ``` -Returns:: The average number of elements per bucket. +[horizontal] +Returns:;; The average number of elements per bucket. --- ==== max_load_factor ```c++ -float max_load_factor() const; +float max_load_factor() const noexcept; ``` -Returns:: Returns the current maximum load factor. +[horizontal] +Returns:;; Returns the current maximum load factor. --- @@ -1303,11 +1268,11 @@ Returns:: Returns the current maximum load factor. void max_load_factor(float z); ``` -Effects:: Changes the container's maximum load factor, using `z` as a hint. +[horizontal] +Effects:;; Changes the container's maximum load factor, using `z` as a hint. --- - ==== rehash ```c++ void rehash(size_type n); @@ -1317,7 +1282,8 @@ Changes the number of buckets so that there at least `n` buckets, and so that th Invalidates iterators, and changes the order of elements. Pointers and references to elements are not invalidated. -Throws:: The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function. +[horizontal] +Throws:;; The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function. --- @@ -1328,60 +1294,58 @@ void reserve(size_type n); Invalidates iterators, and changes the order of elements. Pointers and references to elements are not invalidated. -Throws:: The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function. +[horizontal] +Throws:;; The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function. === Equality Comparisons ==== operator== ```c++ -template< - typename Value, - typename Mapped, - typename Hash, - typename Pred, - typename Alloc> -bool operator==(unordered_set const& x, - unordered_set const& y); +template + bool operator==(const unordered_set& x, + const unordered_set& y); ``` Return `true` if `x.size() == y.size()` and for every element in `x`, there is an element in `y` with the same key, with an equal value (using `operator==` to compare the value types). -Notes:: The behavior of this function was changed to match the C++11 standard in Boost 1.48. Behavior is undefined if the two containers don't have equivalent equality predicates. +[horizontal] +Notes:;; The behavior of this function was changed to match the C++11 standard in Boost 1.48. + ++ +Behavior is undefined if the two containers don't have equivalent equality predicates. --- ==== operator!= ```c++ -template< - typename Value, - typename Mapped, - typename Hash, - typename Pred, - typename Alloc> -bool operator!=(unordered_set const& x, - unordered_set const& y); +template + bool operator!=(const unordered_set& x, + const unordered_set& y); ``` Return `false` if `x.size() == y.size()` and for every element in `x`, there is an element in `y` with the same key, with an equal value (using `operator==` to compare the value types). -Notes:: The behavior of this function was changed to match the C++11 standard in Boost 1.48. Behavior is undefined if the two containers don't have equivalent equality predicates. +[horizontal] +Notes:;; The behavior of this function was changed to match the C++11 standard in Boost 1.48. + ++ +Behavior is undefined if the two containers don't have equivalent equality predicates. + +--- === Swap ```c++ -template -void swap(unordered_set& x, - unordered_set& y); +template + void swap(unordered_set& x, + unordered_set& y) + noexcept(noexcept(x.swap(y))); ``` Swaps the contents of `x` and `y`. If `Allocator::propagate_on_container_swap` is declared and `Allocator::propagate_on_container_swap::value` is `true` then the containers' allocators are swapped. Otherwise, swapping with unequal allocators results in undefined behavior. -Effects:: `x.swap(y)` - -Throws:: Doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of `key_equal` or `hasher`. - -Notes:: The exception specifications aren't quite the same as the C++11 standard, as the equality predicate and hash function are swapped using their copy constructors. - +[horizontal] +Effects:;; `x.swap(y)` +Throws:;; Doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of `key_equal` or `hasher`. +Notes:;; The exception specifications aren't quite the same as the C++11 standard, as the equality predicate and hash function are swapped using their copy constructors. +---