aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/include/__algorithm/move.h
diff options
context:
space:
mode:
authormikhnenko <mikhnenko@yandex-team.com>2023-11-15 21:10:56 +0300
committermikhnenko <mikhnenko@yandex-team.com>2023-11-15 22:24:51 +0300
commit401253f291059c8eb079c95e469cc73af2dc2af5 (patch)
treed8135d1197aaeab6daa5c9dbde39a5916ee98f1d /contrib/libs/cxxsupp/libcxx/include/__algorithm/move.h
parent8e70c7251e94222a2475b7d9b2025b5c33cfd6c1 (diff)
downloadydb-401253f291059c8eb079c95e469cc73af2dc2af5.tar.gz
Upd libc++ to 01 July 2022 da1609ad73540978f66111e96ea500b97ca9b39a
``` [libc++] Improve the formatting of static_assert messages [libc++] Remove dead code and unneeded C++03 specializations from type_traits [libc++] Implement P0618R0 (Deprecating <codecvt>) [libc++] Disentangle _If, _Or and _And Uglify __support/xlocale [libc++][format] Improve pointer formatters. [libc++][format] Improve integral formatters. [libc++] Fix signature of main() in tests [libc++][ranges] Finish LWG issues directly related to the One Ranges Proposal. [libc++] Re-add transitive includes that had been removed since LLVM 14 [libc++] Add a few missing min/max macro push/pop [libc++] Remove dummy command in Dockerfile [libc++] Use bounded iterators in std::span when the debug mode is enabled [libc++] Improve Lit's buildhost=XXXX feature on a few platforms [libc++] Simplify type_traits and use more builtins [libc++] P2321R2 section [tuple.tuple]. Adding C++23 constructors, assignment operators and swaps to `tuple` [libc++][AIX] Make basic_string layout compatible with earlier version [libcxx][test] Suppress complex<int> warnings when testing MSVC [libc++] Add a test to pin down the set of transitive public includes [libc++][format] Copy code to new location. [libc++] Implement ranges::move{, _backward} [libc++] Implement P0154R1 (Hardware inference size) [libc++] Simplify the visibility attributes [libc++] Clarify std::function release note [libc++] Reduces std::to_chars instantiations. [libc++] Fixesbuild. [libc++] fix views::all hard error on lvalue move only views instead of SFINAE [libc++] Complete the implementation of N4190 [libc++] Remove std::function in C++03 [libc++][format] Improve string formatters [libc++] Pass -fno-modules to clang-tidy instead of disabling it for the modules build [libc++][clang-tidy] Enable bugprone-use-after-move and explicitly list all used checks [libc++] Improve charconv base10 algorithm. [libc++][format] Improves the handle test. [libc++] Implement P0174R2 (Deprecating Vestigial Library Parts in C++17) ```
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/__algorithm/move.h')
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/move.h116
1 files changed, 77 insertions, 39 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/move.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/move.h
index 72bf3d76ea..0b08d31c17 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/move.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/move.h
@@ -11,7 +11,10 @@
#include <__algorithm/unwrap_iter.h>
#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/reverse_iterator.h>
#include <__utility/move.h>
+#include <__utility/pair.h>
#include <cstring>
#include <type_traits>
@@ -23,53 +26,88 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// move
-template <class _InputIterator, class _OutputIterator>
+template <class _InIter, class _Sent, class _OutIter>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-_OutputIterator
-__move_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
-{
- for (; __first != __last; ++__first, (void) ++__result)
- *__result = _VSTD::move(*__first);
- return __result;
+pair<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __result) {
+ while (__first != __last) {
+ *__result = std::move(*__first);
+ ++__first;
+ ++__result;
+ }
+ return std::make_pair(std::move(__first), std::move(__result));
}
-template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-_OutputIterator
-__move(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
-{
- return _VSTD::__move_constexpr(__first, __last, __result);
+template <class _InType,
+ class _OutType,
+ class = __enable_if_t<is_same<typename remove_const<_InType>::type, _OutType>::value
+ && is_trivially_move_assignable<_OutType>::value> >
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_InType*, _OutType*> __move_impl(_InType* __first, _InType* __last, _OutType* __result) {
+ if (__libcpp_is_constant_evaluated()
+// TODO: Remove this once GCC supports __builtin_memmove during constant evaluation
+#ifndef _LIBCPP_COMPILER_GCC
+ && !is_trivially_copyable<_InType>::value
+#endif
+ )
+ return std::__move_impl<_InType*, _InType*, _OutType*>(__first, __last, __result);
+ const size_t __n = static_cast<size_t>(__last - __first);
+ ::__builtin_memmove(__result, __first, __n * sizeof(_OutType));
+ return std::make_pair(__first + __n, __result + __n);
}
-template <class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-typename enable_if
-<
- is_same<typename remove_const<_Tp>::type, _Up>::value &&
- is_trivially_move_assignable<_Up>::value,
- _Up*
->::type
-__move(_Tp* __first, _Tp* __last, _Up* __result)
-{
- const size_t __n = static_cast<size_t>(__last - __first);
- if (__n > 0)
- _VSTD::memmove(__result, __first, __n * sizeof(_Up));
- return __result + __n;
+template <class>
+struct __is_trivially_move_assignable_unwrapped_impl : false_type {};
+
+template <class _Type>
+struct __is_trivially_move_assignable_unwrapped_impl<_Type*> : is_trivially_move_assignable<_Type> {};
+
+template <class _Iter>
+struct __is_trivially_move_assignable_unwrapped
+ : __is_trivially_move_assignable_unwrapped_impl<decltype(std::__unwrap_iter<_Iter>(std::declval<_Iter>()))> {};
+
+template <class _InIter,
+ class _OutIter,
+ __enable_if_t<is_same<typename remove_const<typename iterator_traits<_InIter>::value_type>::type,
+ typename iterator_traits<_OutIter>::value_type>::value
+ && __is_cpp17_contiguous_iterator<_InIter>::value
+ && __is_cpp17_contiguous_iterator<_OutIter>::value
+ && is_trivially_move_assignable<__iter_value_type<_OutIter> >::value, int> = 0>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+pair<reverse_iterator<_InIter>, reverse_iterator<_OutIter> >
+__move_impl(reverse_iterator<_InIter> __first,
+ reverse_iterator<_InIter> __last,
+ reverse_iterator<_OutIter> __result) {
+ auto __first_base = std::__unwrap_iter(__first.base());
+ auto __last_base = std::__unwrap_iter(__last.base());
+ auto __result_base = std::__unwrap_iter(__result.base());
+ auto __result_first = __result_base - (__first_base - __last_base);
+ std::__move_impl(__last_base, __first_base, __result_first);
+ return std::make_pair(__last, reverse_iterator<_OutIter>(std::__rewrap_iter(__result.base(), __result_first)));
+}
+
+template <class _InIter, class _Sent, class _OutIter>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+__enable_if_t<is_copy_constructible<_InIter>::value
+ && is_copy_constructible<_Sent>::value
+ && is_copy_constructible<_OutIter>::value, pair<_InIter, _OutIter> >
+__move(_InIter __first, _Sent __last, _OutIter __result) {
+ auto __ret = std::__move_impl(std::__unwrap_iter(__first), std::__unwrap_iter(__last), std::__unwrap_iter(__result));
+ return std::make_pair(std::__rewrap_iter(__first, __ret.first), std::__rewrap_iter(__result, __ret.second));
+}
+
+template <class _InIter, class _Sent, class _OutIter>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+__enable_if_t<!is_copy_constructible<_InIter>::value
+ || !is_copy_constructible<_Sent>::value
+ || !is_copy_constructible<_OutIter>::value, pair<_InIter, _OutIter> >
+__move(_InIter __first, _Sent __last, _OutIter __result) {
+ return std::__move_impl(std::move(__first), std::move(__last), std::move(__result));
}
template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-move(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
-{
- if (__libcpp_is_constant_evaluated()) {
- return _VSTD::__move_constexpr(__first, __last, __result);
- } else {
- return _VSTD::__rewrap_iter(__result,
- _VSTD::__move(_VSTD::__unwrap_iter(__first),
- _VSTD::__unwrap_iter(__last),
- _VSTD::__unwrap_iter(__result)));
- }
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
+ return std::__move(__first, __last, __result).second;
}
_LIBCPP_END_NAMESPACE_STD