[libcxx-commits] [libcxx] [libc++] Avoid constructing additional objects when using map::at (PR #157866)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Sep 15 08:27:22 PDT 2025
================
@@ -1085,6 +1094,30 @@ public:
_LIBCPP_HIDE_FROM_ABI mapped_type& operator[](key_type&& __k);
# endif
+ template <class _Arg,
+ __enable_if_t<is_convertible<_Arg, value_type>::value &&
+ __desugars_to_v<__less_tag, key_compare, key_type, key_type> &&
----------------
ldionne wrote:
We should find a way to not list comparators explicitly here. This basically encodes whether we're allowed to assume that a comparator marked as transparent (via `is_transparent`) behaves like we'd think. This should be its own trait, and it should also be the target of a LWG issue clarifying the properties of transparent comparators.
If we had such clarification, then we could drop that trait because we could assume that a comparator marked with `is_transparent` behaves sanely.
The `enable_if` would become this:
```
is_convertible<_Arg, value_type>::value && // for standards conformance
!__is_true_transparent_comparator_v<__make_transparent_t<key_compare> > && // there exists an equivalent "true" transparent comparator
__is_transparently_comparable_v<key_type, __remove_cvref_t<_Arg> > // skipping the conversion is fine
```
https://github.com/llvm/llvm-project/pull/157866
More information about the libcxx-commits
mailing list