aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/include/__algorithm/make_projected.h
diff options
context:
space:
mode:
authorhiddenpath <hiddenpath@yandex-team.com>2023-12-06 01:17:18 +0300
committerhiddenpath <hiddenpath@yandex-team.com>2023-12-06 01:59:21 +0300
commit525f68b21befc656ea5f25bb7e30035d2d350768 (patch)
tree961461b8e22c97629f0cf96c09708f2c4555998c /contrib/libs/cxxsupp/libcxx/include/__algorithm/make_projected.h
parentd663b05d2ce78f55bfdd6823d01986944391f4a7 (diff)
downloadydb-525f68b21befc656ea5f25bb7e30035d2d350768.tar.gz
Upd libc++ to 12 July 2022 81c48436bbd29736f77a111fc207e28854939907
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/__algorithm/make_projected.h')
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/make_projected.h22
1 files changed, 21 insertions, 1 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/make_projected.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/make_projected.h
index 8141c4ed176..6d8ebfd3d90 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/make_projected.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/make_projected.h
@@ -13,6 +13,8 @@
#include <__config>
#include <__functional/identity.h>
#include <__functional/invoke.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_member_pointer.h>
#include <__utility/forward.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -28,7 +30,7 @@ namespace ranges {
template <class _Comp, class _Proj>
_LIBCPP_HIDE_FROM_ABI constexpr static
decltype(auto) __make_projected_comp(_Comp& __comp, _Proj& __proj) {
- if constexpr (same_as<_Proj, identity>) {
+ if constexpr (same_as<decay_t<_Proj>, identity> && !is_member_pointer_v<decay_t<_Comp>>) {
// Avoid creating the lambda and just use the pristine comparator -- for certain algorithms, this would enable
// optimizations that rely on the type of the comparator.
return __comp;
@@ -42,6 +44,24 @@ decltype(auto) __make_projected_comp(_Comp& __comp, _Proj& __proj) {
}
}
+template <class _Comp, class _Proj1, class _Proj2>
+_LIBCPP_HIDE_FROM_ABI constexpr static
+decltype(auto) __make_projected_comp(_Comp& __comp, _Proj1& __proj1, _Proj2& __proj2) {
+ if constexpr (same_as<decay_t<_Proj1>, identity> && same_as<decay_t<_Proj2>, identity> &&
+ !is_member_pointer_v<decay_t<_Comp>>) {
+ // Avoid creating the lambda and just use the pristine comparator -- for certain algorithms, this would enable
+ // optimizations that rely on the type of the comparator.
+ return __comp;
+
+ } else {
+ return [&](auto&& __lhs, auto&& __rhs) {
+ return std::invoke(__comp,
+ std::invoke(__proj1, std::forward<decltype(__lhs)>(__lhs)),
+ std::invoke(__proj2, std::forward<decltype(__rhs)>(__rhs)));
+ };
+ }
+}
+
} // namespace ranges
_LIBCPP_END_NAMESPACE_STD