[libcxx-commits] [libcxx] [libc++] Make lazy three way comparator optimization apply in older standard modes (PR #218525)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Aug 26 06:56:20 PDT 2026
================
@@ -713,16 +714,16 @@ template <class _MapValueT, class _Key, class _TransparentKey, class _Compare>
struct __lazy_synth_three_way_comparator<__map_value_compare<_Key, _MapValueT, _Compare>, _MapValueT, _TransparentKey> {
__lazy_synth_three_way_comparator<_Compare, _Key, _TransparentKey> __comp_;
- __lazy_synth_three_way_comparator(
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 __lazy_synth_three_way_comparator(
_LIBCPP_CTOR_LIFETIMEBOUND const __map_value_compare<_Key, _MapValueT, _Compare>& __comp)
: __comp_(__comp.key_comp()) {}
- _LIBCPP_HIDE_FROM_ABI auto
- operator()(_LIBCPP_LIFETIMEBOUND const _MapValueT& __lhs, _LIBCPP_LIFETIMEBOUND const _TransparentKey& __rhs) const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 auto
+ operator()(_LIBCPP_LIFETIMEBOUND const _MapValueT& __lhs, _LIBCPP_LIFETIMEBOUND const _TransparentKey& __rhs) const
+ -> decltype(__comp_(__lhs.first, __rhs)) {
----------------
zhangweize9-cyber wrote:
> I guess we may want to make this compile in C++03 mode, although the old style is really verbose.
> ```suggestion
> _LIBCPP_HIDE_FROM_ABI
> _LIBCPP_CONSTEXPR_SINCE_CXX26 decltype(std::declval<const __lazy_synth_three_way_comparator<_Compare, _Key, _Key>&>()(
> std::declval<const _MapValueT&>().first, std::declval<const _TransparentKey&>()))
> operator()(_LIBCPP_LIFETIMEBOUND const _MapValueT& __lhs, _LIBCPP_LIFETIMEBOUND const _TransparentKey& __rhs) const {
> ```
>
> (Same above. We should also include `<__utility/declval.h>` for this.)
I don't recommend making this change. `_LIBCPP_HIDE_FROM_ABI` is an ABI hiding macro simply to hide ABI symbols and prevent dynamic library conflicts.
https://github.com/llvm/llvm-project/pull/218525
More information about the libcxx-commits
mailing list