aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/include/__algorithm/make_projected.h
diff options
context:
space:
mode:
authormikhnenko <mikhnenko@yandex-team.com>2023-11-07 19:02:37 +0300
committermikhnenko <mikhnenko@yandex-team.com>2023-11-07 19:40:24 +0300
commitc67f6bf0e38c3e450cf3fb320b3db868fd4b5fe8 (patch)
treed4662b2c9af0f2658f74c56d1d1e5cb672f34680 /contrib/libs/cxxsupp/libcxx/include/__algorithm/make_projected.h
parentaa4bbf0349f5ee93d10e133c1d79cb5151f853f0 (diff)
downloadydb-c67f6bf0e38c3e450cf3fb320b3db868fd4b5fe8.tar.gz
Upd libc++ to 18 Jun 2022 ff3989e6ae740a9b3adaad0e2bf7691ffd6dad12
``` [libc++] Add Implemented Papers section [libc++] Enable -Wweak-vtables [libc++] Make sure we install libc++abi headers on Apple [libc++] Don't force -O2 when building the benchmarks [libc++] Mark standard-mandated includes as such [libc++] Implement std::boyer_moore{, _horspool}_searcher [libc++] Unwrap reverse_iterator<reverse_iterator<Iter>> in __unwrap_iter [libc++] Simplify __config a bit [libc++][ranges] Implement `ranges::sort`. [libc++] Remove now-unused experimental/filesystem config file [libc++] Robust against C++20-hostile iterators [libc++] Implement ranges::lexicographical_compare [libc++] Removes unneeded <iterator> includes. [libcxx] Fix allocator<void>::pointer in C++20 with removed members [libcxx] Remove extraneous '---' lines in .clang-format files [libc++][NFCI] span: replace enable_if with concepts [libc++] Find a clang-format everybody is happy with [libc++] Use explicit module cache path in tests [libc++] Remove macros for IBM compiler ```
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/__algorithm/make_projected.h')
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/make_projected.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/make_projected.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/make_projected.h
new file mode 100644
index 0000000000..8141c4ed17
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/make_projected.h
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_MAKE_PROJECTED_H
+#define _LIBCPP___ALGORITHM_MAKE_PROJECTED_H
+
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__utility/forward.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+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>) {
+ // 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(__proj, std::forward<decltype(__lhs)>(__lhs)),
+ std::invoke(__proj, std::forward<decltype(__rhs)>(__rhs)));
+ };
+ }
+}
+
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_MAKE_PROJECTED_H