|
2171 | 2171 |
|
2172 | 2172 | \pnum
|
2173 | 2173 | \indextext{unordered associative containers!equality function}%
|
2174 |
| -Two values \tcode{k1} and \tcode{k2} of type \tcode{Key} are |
| 2174 | +Two values \tcode{k1} and \tcode{k2} are |
2175 | 2175 | considered equivalent if the container's
|
2176 |
| -key equality predicate returns |
| 2176 | +key equality predicate |
| 2177 | +\tcode{pred(k1, k2)} is valid and returns |
2177 | 2178 | \tcode{true} when passed those values. If \tcode{k1} and
|
2178 | 2179 | \tcode{k2} are equivalent, the container's hash function shall
|
2179 | 2180 | return the same value for both.
|
|
2257 | 2258 | \tcode{b} denotes a possibly const value of type \tcode{X},
|
2258 | 2259 | \tcode{a_uniq} denotes a value of type \tcode{X} when \tcode{X} supports unique keys,
|
2259 | 2260 | \tcode{a_eq} denotes a value of type \tcode{X} when \tcode{X} supports equivalent keys,
|
| 2261 | +\tcode{a_tran} denotes a possibly const value of type \tcode{X} |
| 2262 | +when the \grammarterm{qualified-id} \tcode{X::hasher::transparent_key_equal} |
| 2263 | +is valid and denotes a type\iref{temp.deduct}, |
2260 | 2264 | \tcode{i} and \tcode{j} denote input iterators that refer to \tcode{value_type},
|
2261 | 2265 | \tcode{[i, j)} denotes a valid range,
|
2262 | 2266 | \tcode{p} and \tcode{q2} denote valid constant iterators to \tcode{a},
|
|
2268 | 2272 | \tcode{k} denotes a value of type \tcode{key_type},
|
2269 | 2273 | \tcode{hf} denotes a possibly const value of type \tcode{hasher},
|
2270 | 2274 | \tcode{eq} denotes a possibly const value of type \tcode{key_equal},
|
| 2275 | +\tcode{ke} is a value such that |
| 2276 | +(1) \tcode{eq(r1, ke) == eq(ke, r1)} |
| 2277 | +with \tcode{r1} the key value of \tcode{e} and \tcode{e} in \tcode{a_tran}, |
| 2278 | +(2) \tcode{hf(r1) == hf(ke)} if \tcode{eq(r1, ke)} is \tcode{true}, and |
| 2279 | +(3) \tcode{(eq(r1, ke) \&\& eq(r1, r2)) == eq(r2, ke)} |
| 2280 | +where \tcode{r2} is the key of an element in \tcode{a_tran}, |
2271 | 2281 | \tcode{n} denotes a value of type \tcode{size_type},
|
2272 | 2282 | \tcode{z} denotes a value of type \tcode{float},
|
2273 | 2283 | and \tcode{nh} denotes a non-const rvalue of type \tcode{X::node_type}.
|
|
2327 | 2337 | %
|
2328 | 2338 | \indexunordmem{key_equal}%
|
2329 | 2339 | \tcode{X::key_equal}
|
2330 |
| -& \tcode{Pred} |
| 2340 | +& \tcode{Hash::transparent_key_equal} if such a \grammarterm{qualified-id} |
| 2341 | + is valid and denotes a type\iref{temp.deduct}; |
| 2342 | + otherwise, \tcode{Pred}. |
2331 | 2343 | & \requires\ \tcode{Pred} is \oldconcept{CopyConstructible}.\br
|
2332 | 2344 | \tcode{Pred} shall be a binary predicate that takes two arguments
|
2333 | 2345 | of type \tcode{Key}. \tcode{Pred} is an equivalence relation.%
|
|
2721 | 2733 | & Average case \bigoh{1}, worst case \bigoh{\tcode{b.size()}}.
|
2722 | 2734 | \\ \rowsep
|
2723 | 2735 | %
|
| 2736 | +\tcode{a_tran.find(ke)} |
| 2737 | +& \tcode{iterator}; \br \tcode{const_iterator} for const \tcode{a_tran}. |
| 2738 | +& Returns an iterator pointing to an element with key equivalent to |
| 2739 | + \tcode{ke}, or \tcode{a_tran.end()} if no such element exists.% |
| 2740 | +& Average case \bigoh{1}, |
| 2741 | + worst case \bigoh{\tcode{a_tran.}\br{}\tcode{size()}}. % avoid wverfull |
| 2742 | +\\ \rowsep |
| 2743 | +% |
2724 | 2744 | \indexunordmem{count}%
|
2725 | 2745 | \tcode{b.count(k)}
|
2726 | 2746 | & \tcode{size_type}
|
2727 | 2747 | & Returns the number of elements with key equivalent to \tcode{k}.%
|
2728 | 2748 | & Average case \bigoh{\tcode{b.count(k)}}, worst case \bigoh{\tcode{b.size()}}.
|
2729 | 2749 | \\ \rowsep
|
2730 | 2750 | %
|
| 2751 | +\tcode{a_tran.count(ke)} |
| 2752 | +& \tcode{size_type} |
| 2753 | +& Returns the number of elements with key equivalent to \tcode{ke}.% |
| 2754 | +& Average case |
| 2755 | + \bigoh{\tcode{a_tran.}\br{}\tcode{count(ke)}}, % avoid overfull |
| 2756 | + worst case \bigoh{\tcode{a_tran.}\br{}\tcode{size()}}. % avoid overfull |
| 2757 | +\\ \rowsep |
| 2758 | +% |
2731 | 2759 | \indexunordmem{contains}%
|
2732 | 2760 | \tcode{b.contains(k)}
|
2733 | 2761 | & \tcode{bool}
|
2734 | 2762 | & Equivalent to \tcode{b.find(k) != b.end()}%
|
2735 | 2763 | & Average case \bigoh{1}, worst case \bigoh{\tcode{b.size()}}.
|
2736 | 2764 | \\ \rowsep
|
2737 | 2765 | %
|
| 2766 | +\tcode{a_tran.contains(ke)} |
| 2767 | +& \tcode{bool} |
| 2768 | +& Equivalent to \tcode{a_tran.find(ke) != a_tran.end()}% |
| 2769 | +& Average case \bigoh{1}, |
| 2770 | + worst case \bigoh{\tcode{a_tran.}\br{}\tcode{size()}}. % avoid overfull |
| 2771 | +\\ \rowsep |
| 2772 | +% |
2738 | 2773 | \indexunordmem{equal_range}%
|
2739 | 2774 | \tcode{b.equal_range(k)}
|
2740 | 2775 | & \tcode{pair<iterator, iterator>}; \br
|
|
2746 | 2781 | \bigoh{\tcode{b.size()}}.
|
2747 | 2782 | \\ \rowsep
|
2748 | 2783 | %
|
| 2784 | +\tcode{a_tran.equal_range(ke)} |
| 2785 | +& \tcode{pair<iterator, iterator>}; \br |
| 2786 | + \tcode{pair<const_iterator, const_iterator>} for const \tcode{a_tran}. |
| 2787 | +& Returns a range containing all elements with keys equivalent to |
| 2788 | + \tcode{ke}. Returns \tcode{make_pair(a_tran.end(), a_tran.end())} if |
| 2789 | + no such elements exist.% |
| 2790 | +& Average case |
| 2791 | + \bigoh{\tcode{a_tran.}\br{}\tcode{count(ke)}}. % avoid overfull |
| 2792 | + Worst case \bigoh{\tcode{a_tran.}\br{}\tcode{size()}}. % avoid overfull |
| 2793 | +\\ \rowsep |
2749 | 2794 | \indexunordmem{bucket_count}%
|
2750 | 2795 | \tcode{b.bucket_count()}
|
2751 | 2796 | & \tcode{size_type}
|
|
2924 | 2969 | obtained while it is owned by a \tcode{node_type} are invalidated if the
|
2925 | 2970 | element is successfully inserted.
|
2926 | 2971 |
|
| 2972 | +\pnum |
| 2973 | +If the \grammarterm{qualified-id} \tcode{Hash::transparent_key_equal} |
| 2974 | +is valid and denotes a type\iref{temp.deduct}. |
| 2975 | +then the program is ill-formed if either: |
| 2976 | +\begin{itemize} |
| 2977 | +\item |
| 2978 | + \grammarterm{qualified-id} \tcode{Hash::transparent_key_equal::is_transparent} |
| 2979 | + is not valid or does not denote a type, or |
| 2980 | +\item |
| 2981 | + \tcode{Pred} is a different type than \tcode{equal_to<Key>} or |
| 2982 | + \tcode{Hash::transparent_key_equal}. |
| 2983 | +\end{itemize} |
| 2984 | +The member function templates |
| 2985 | +\tcode{find}, \tcode{count}, \tcode{equal_range}, and \tcode{contains} |
| 2986 | +shall not participate in overload resolution unless |
| 2987 | +the \grammarterm{qualified-id} \tcode{Hash::transparent_key_equal} |
| 2988 | +is valid and denotes a type\iref{temp.deduct}. |
| 2989 | + |
2927 | 2990 | \pnum
|
2928 | 2991 | A deduction guide for an unordered associative container shall not participate in overload resolution
|
2929 | 2992 | if any of the following are true:
|
|
7486 | 7549 | using mapped_type = T;
|
7487 | 7550 | using value_type = pair<const Key, T>;
|
7488 | 7551 | using hasher = Hash;
|
7489 |
| - using key_equal = Pred; |
| 7552 | + using key_equal = @\seeref{unord.req}@; |
7490 | 7553 | using allocator_type = Allocator;
|
7491 | 7554 | using pointer = typename allocator_traits<Allocator>::pointer;
|
7492 | 7555 | using const_pointer = typename allocator_traits<Allocator>::const_pointer;
|
|
7620 | 7683 | key_equal key_eq() const;
|
7621 | 7684 |
|
7622 | 7685 | // map operations
|
7623 |
| - iterator find(const key_type& k); |
7624 |
| - const_iterator find(const key_type& k) const; |
7625 |
| - size_type count(const key_type& k) const; |
7626 |
| - bool contains(const key_type& k) const; |
7627 |
| - pair<iterator, iterator> equal_range(const key_type& k); |
7628 |
| - pair<const_iterator, const_iterator> equal_range(const key_type& k) const; |
| 7686 | + iterator find(const key_type& k); |
| 7687 | + const_iterator find(const key_type& k) const; |
| 7688 | + template <class K> |
| 7689 | + iterator find(const K& k); |
| 7690 | + template <class K> |
| 7691 | + const_iterator find(const K& k) const; |
| 7692 | + size_type count(const key_type& k) const; |
| 7693 | + template <class K> |
| 7694 | + size_type count(const K& k) const; |
| 7695 | + bool contains(const key_type& k) const; |
| 7696 | + template <class K> |
| 7697 | + bool contains(const K& k) const; |
| 7698 | + pair<iterator, iterator> equal_range(const key_type& k); |
| 7699 | + pair<const_iterator, const_iterator> equal_range(const key_type& k) const; |
| 7700 | + template <class K> |
| 7701 | + pair<iterator, iterator> equal_range(const K& k); |
| 7702 | + template <class K> |
| 7703 | + pair<const_iterator, const_iterator> equal_range(const K& k) const; |
7629 | 7704 |
|
7630 | 7705 | // \ref{unord.map.elem}, element access
|
7631 | 7706 | mapped_type& operator[](const key_type& k);
|
|
8033 | 8108 | using mapped_type = T;
|
8034 | 8109 | using value_type = pair<const Key, T>;
|
8035 | 8110 | using hasher = Hash;
|
8036 |
| - using key_equal = Pred; |
| 8111 | + using key_equal = @\seeref{unord.req}@; |
8037 | 8112 | using allocator_type = Allocator;
|
8038 | 8113 | using pointer = typename allocator_traits<Allocator>::pointer;
|
8039 | 8114 | using const_pointer = typename allocator_traits<Allocator>::const_pointer;
|
|
8149 | 8224 | key_equal key_eq() const;
|
8150 | 8225 |
|
8151 | 8226 | // map operations
|
8152 |
| - iterator find(const key_type& k); |
8153 |
| - const_iterator find(const key_type& k) const; |
8154 |
| - size_type count(const key_type& k) const; |
8155 |
| - bool contains(const key_type& k) const; |
8156 |
| - pair<iterator, iterator> equal_range(const key_type& k); |
8157 |
| - pair<const_iterator, const_iterator> equal_range(const key_type& k) const; |
| 8227 | + iterator find(const key_type& k); |
| 8228 | + const_iterator find(const key_type& k) const; |
| 8229 | + template <class K> |
| 8230 | + iterator find(const K& k); |
| 8231 | + template <class K> |
| 8232 | + const_iterator find(const K& k) const; |
| 8233 | + size_type count(const key_type& k) const; |
| 8234 | + template <class K> |
| 8235 | + size_type count(const K& k) const; |
| 8236 | + bool contains(const key_type& k) const; |
| 8237 | + template <class K> |
| 8238 | + bool contains(const K& k) const; |
| 8239 | + pair<iterator, iterator> equal_range(const key_type& k); |
| 8240 | + pair<const_iterator, const_iterator> equal_range(const key_type& k) const; |
| 8241 | + template <class K> |
| 8242 | + pair<iterator, iterator> equal_range(const K& k); |
| 8243 | + template <class K> |
| 8244 | + pair<const_iterator, const_iterator> equal_range(const K& k) const; |
8158 | 8245 |
|
8159 | 8246 | // bucket interface
|
8160 | 8247 | size_type bucket_count() const noexcept;
|
|
8361 | 8448 | using key_type = Key;
|
8362 | 8449 | using value_type = Key;
|
8363 | 8450 | using hasher = Hash;
|
8364 |
| - using key_equal = Pred; |
| 8451 | + using key_equal = @\seeref{unord.req}@; |
8365 | 8452 | using allocator_type = Allocator;
|
8366 | 8453 | using pointer = typename allocator_traits<Allocator>::pointer;
|
8367 | 8454 | using const_pointer = typename allocator_traits<Allocator>::const_pointer;
|
|
8476 | 8563 | key_equal key_eq() const;
|
8477 | 8564 |
|
8478 | 8565 | // set operations
|
8479 |
| - iterator find(const key_type& k); |
8480 |
| - const_iterator find(const key_type& k) const; |
8481 |
| - size_type count(const key_type& k) const; |
8482 |
| - bool contains(const key_type& k) const; |
8483 |
| - pair<iterator, iterator> equal_range(const key_type& k); |
8484 |
| - pair<const_iterator, const_iterator> equal_range(const key_type& k) const; |
| 8566 | + iterator find(const key_type& k); |
| 8567 | + const_iterator find(const key_type& k) const; |
| 8568 | + template <class K> |
| 8569 | + iterator find(const K& k); |
| 8570 | + template <class K> |
| 8571 | + const_iterator find(const K& k) const; |
| 8572 | + size_type count(const key_type& k) const; |
| 8573 | + template <class K> |
| 8574 | + size_type count(const K& k) const; |
| 8575 | + bool contains(const key_type& k) const; |
| 8576 | + template <class K> |
| 8577 | + bool contains(const K& k) const; |
| 8578 | + pair<iterator, iterator> equal_range(const key_type& k); |
| 8579 | + pair<const_iterator, const_iterator> equal_range(const key_type& k) const; |
| 8580 | + template <class K> |
| 8581 | + pair<iterator, iterator> equal_range(const K& k); |
| 8582 | + template <class K> |
| 8583 | + pair<const_iterator, const_iterator> equal_range(const K& k) const; |
8485 | 8584 |
|
8486 | 8585 | // bucket interface
|
8487 | 8586 | size_type bucket_count() const noexcept;
|
|
8651 | 8750 | using key_type = Key;
|
8652 | 8751 | using value_type = Key;
|
8653 | 8752 | using hasher = Hash;
|
8654 |
| - using key_equal = Pred; |
| 8753 | + using key_equal = @\seeref{unord.req}@; |
8655 | 8754 | using allocator_type = Allocator;
|
8656 | 8755 | using pointer = typename allocator_traits<Allocator>::pointer;
|
8657 | 8756 | using const_pointer = typename allocator_traits<Allocator>::const_pointer;
|
|
8765 | 8864 | key_equal key_eq() const;
|
8766 | 8865 |
|
8767 | 8866 | // set operations
|
8768 |
| - iterator find(const key_type& k); |
8769 |
| - const_iterator find(const key_type& k) const; |
8770 |
| - size_type count(const key_type& k) const; |
8771 |
| - bool contains(const key_type& k) const; |
8772 |
| - pair<iterator, iterator> equal_range(const key_type& k); |
8773 |
| - pair<const_iterator, const_iterator> equal_range(const key_type& k) const; |
| 8867 | + iterator find(const key_type& k); |
| 8868 | + const_iterator find(const key_type& k) const; |
| 8869 | + template <class K> |
| 8870 | + iterator find(const K& k); |
| 8871 | + template <class K> |
| 8872 | + const_iterator find(const K& k) const; |
| 8873 | + size_type count(const key_type& k) const; |
| 8874 | + template <class K> |
| 8875 | + size_type count(const K& k) const; |
| 8876 | + bool contains(const key_type& k) const; |
| 8877 | + template <class K> |
| 8878 | + bool contains(const K& k) const; |
| 8879 | + pair<iterator, iterator> equal_range(const key_type& k); |
| 8880 | + pair<const_iterator, const_iterator> equal_range(const key_type& k) const; |
| 8881 | + template <class K> |
| 8882 | + pair<iterator, iterator> equal_range(const K& k); |
| 8883 | + template <class K> |
| 8884 | + pair<const_iterator, const_iterator> equal_range(const K& k) const; |
8774 | 8885 |
|
8775 | 8886 | // bucket interface
|
8776 | 8887 | size_type bucket_count() const noexcept;
|
|
0 commit comments