[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
Wed Sep 17 09:04:03 PDT 2025
================
@@ -65,6 +67,12 @@ template <class _CanonicalTag, class _Operation, class... _Args>
inline const bool __desugars_to_v<_CanonicalTag, _Operation&&, _Args...> =
__desugars_to_v<_CanonicalTag, _Operation, _Args...>;
+#if _LIBCPP_STD_VER >= 14 // transparent compators are only available since C++14
+template <class _Operation, class... _Args>
+inline const bool __desugars_to_v<__potentially_transparent_comp_tag, _Operation, _Args...> =
----------------
ldionne wrote:
I would rather introduce a new trait than expand the meaning of `__desugars_to`. What we're trying to encode here is that a transparent operation has a "regular" behavior (that works generically with any type). I think the name of the trait should focus on making that clear.
```c++
template <class _Operation>
inline const bool __is_generic_transparent_comparator_v = false;
template <> inline const bool __is_generic_transparent_comparator_v<less<>> = true;
template <> inline const bool __is_generic_transparent_comparator_v<ranges::less<>> = true;
template <> inline const bool __is_generic_transparent_comparator_v<__less<>> = true;
```
And then we call `__is_generic_transparent_comparator_v` on the result of `__make_transparent`, to check whether the transparent comparator is something that behaves in a natural fashion.
https://github.com/llvm/llvm-project/pull/157866
More information about the libcxx-commits
mailing list