diff options
author | Abseil Team <absl-team@google.com> | 2023-11-28 01:48:43 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-11-28 01:49:21 -0800 |
commit | 0c09fd0ff0d502c30831ff2ccf59894e36d2b60a (patch) | |
tree | 2912a44c2ac83dd81b9001aa9b141b86b468283d | |
parent | ac7ec8ea872b1686e7ad4135449b4b65c9324732 (diff) |
`btree_map`: avoid a copy in `map_params::key`.
PiperOrigin-RevId: 585892739
Change-Id: I30490dac5826bff2a33d9872f71154d360f9cc0d
-rw-r--r-- | absl/container/btree_map.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/absl/container/btree_map.h b/absl/container/btree_map.h index cd3ee2b4..0f62f0bd 100644 --- a/absl/container/btree_map.h +++ b/absl/container/btree_map.h @@ -53,6 +53,7 @@ #ifndef ABSL_CONTAINER_BTREE_MAP_H_ #define ABSL_CONTAINER_BTREE_MAP_H_ +#include "absl/base/attributes.h" #include "absl/container/internal/btree.h" // IWYU pragma: export #include "absl/container/internal/btree_container.h" // IWYU pragma: export @@ -864,7 +865,8 @@ struct map_params : common_params<Key, Compare, Alloc, TargetNodeSize, IsMulti, using init_type = typename super_type::init_type; template <typename V> - static auto key(const V &value) -> decltype(value.first) { + static auto key(const V &value ABSL_ATTRIBUTE_LIFETIME_BOUND) + -> decltype((value.first)) { return value.first; } static const Key &key(const slot_type *s) { return slot_policy::key(s); } |