Chromium Code Reviews| Index: base/containers/flat_map.h |
| diff --git a/base/containers/flat_map.h b/base/containers/flat_map.h |
| index ce50dcd736046851016029011e19542c7ae6f891..125b804292d7e85e1cc1eabaa68d4c92e37e6986 100644 |
| --- a/base/containers/flat_map.h |
| +++ b/base/containers/flat_map.h |
| @@ -8,6 +8,7 @@ |
| #include <utility> |
| #include "base/containers/flat_tree.h" |
| +#include "base/functional.h" |
| #include "base/logging.h" |
| namespace base { |
| @@ -37,6 +38,8 @@ struct GetKeyFromValuePairFirst { |
| // - Low overhead, especially for smaller maps. |
| // - Performance is good for more workloads than you might expect (see |
| // overview link above). |
| +// - Supports C++14 set interface. |
| +// - Uses base::less which can compare pointers and smart pointers. |
| // |
| // CONS |
| // |
| @@ -94,33 +97,44 @@ struct GetKeyFromValuePairFirst { |
| // const_reverse_iterator crend() const; |
| // |
| // Insert and accessor functions: |
| -// Mapped& operator[](const Key&); |
| -// Mapped& operator[](Key&&); |
| -// pair<iterator, bool> insert(const pair<Key, Mapped>&); |
| -// pair<iterator, bool> insert(pair<Key, Mapped>&&); |
| +// Mapped& operator[](const key_type&); |
| +// Mapped& operator[](key_type&&); |
| +// pair<iterator, bool> insert(const value_type&); |
| +// pair<iterator, bool> insert(value_type&&); |
| // void insert(InputIterator first, InputIterator last, |
| // FlatContainerDupes); |
| +// template <typename ...Args> |
|
brettw
2017/06/20 18:13:35
I find these ...Args template lines make it more d
|
| // pair<iterator, bool> emplace(Args&&...); |
| +// template <typename ...Args> |
| // iterator emplace_hint(const_iterator, Args&&...); |
| // |
| // Erase functions: |
| +// iterator erase(iterator); |
| // iterator erase(const_iterator); |
| // iterator erase(const_iterator first, const_iterator& last); |
| -// size_t erase(const Key& key) |
| +// template <typename K> |
| +// size_t erase(const K& key) |
|
brettw
2017/06/20 18:13:35
Here and in the ones below we really need the temp
|
| // |
| // Comparators (see std::map documentation). |
| // key_compare key_comp() const; |
| // value_compare value_comp() const; |
| // |
| // Search functions: |
| -// size_t count(const Key&) const; |
| -// iterator find(const Key&); |
| -// const_iterator find(const Key&) const; |
| -// pair<iterator, iterator> equal_range(Key&) |
| -// iterator lower_bound(const Key&); |
| -// const_iterator lower_bound(const Key&) const; |
| -// iterator upper_bound(const Key&); |
| -// const_iterator upper_bound(const Key&) const; |
| +// template <typename K> |
| +// size_t count(const K&) const; |
| +// template <typename K> |
| +// iterator find(const K&); |
| +// template <typename K> |
| +// const_iterator find(const K&) const; |
| +// template <typename K> |
| +// pair<iterator, iterator> equal_range(const K&); |
| +// template <typename K> |
| +// iterator lower_bound(const K&); |
| +// template <typename K> |
| +// const_iterator lower_bound(const K&) const; |
| +// template <typename K> |
| +// iterator upper_bound(const K&); |
| +// const_iterator upper_bound(const K&) const; |
| // |
| // General functions: |
| // void swap(flat_map&&) |
| @@ -133,7 +147,7 @@ struct GetKeyFromValuePairFirst { |
| // bool operator>=(const flat_map&, const flat_map); |
| // bool operator<=(const flat_map&, const flat_map); |
| // |
| -template <class Key, class Mapped, class Compare = std::less<Key>> |
| +template <class Key, class Mapped, class Compare = less> |
| // Meets the requirements of Container, AssociativeContainer, |
| // ReversibleContainer. |
| // Requires: Key is Movable, Compare is a StrictWeakOrdering on Key. |