Commit 0c09fd0f by Abseil Team Committed by Copybara-Service

`btree_map`: avoid a copy in `map_params::key`.

PiperOrigin-RevId: 585892739
Change-Id: I30490dac5826bff2a33d9872f71154d360f9cc0d
parent ac7ec8ea
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
#ifndef ABSL_CONTAINER_BTREE_MAP_H_ #ifndef ABSL_CONTAINER_BTREE_MAP_H_
#define 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.h" // IWYU pragma: export
#include "absl/container/internal/btree_container.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, ...@@ -864,7 +865,8 @@ struct map_params : common_params<Key, Compare, Alloc, TargetNodeSize, IsMulti,
using init_type = typename super_type::init_type; using init_type = typename super_type::init_type;
template <typename V> 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; return value.first;
} }
static const Key &key(const slot_type *s) { return slot_policy::key(s); } static const Key &key(const slot_type *s) { return slot_policy::key(s); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment