diff options
author | mikhnenko <mikhnenko@yandex-team.com> | 2024-01-26 10:38:46 +0300 |
---|---|---|
committer | mikhnenko <mikhnenko@yandex-team.com> | 2024-01-26 11:13:08 +0300 |
commit | 885b105cca4721eee2ee14d6b83d856dac3739ef (patch) | |
tree | c40b876bba01bcb469aadd981ef6d9dcbbbd589d /contrib/libs/cxxsupp/libcxx/include/__algorithm/move.h | |
parent | 15e6154017194456fd8a7a76513e14aa4ae5f5d1 (diff) | |
download | ydb-885b105cca4721eee2ee14d6b83d856dac3739ef.tar.gz |
Update libcxx to 02 June 2023 185b81e034ba60081023b6e59504dfffb560f3e3 (llvmorg-16.0.5)
:warning: Для всех проектов и мимо проходящим коллегам :warning:
Если по каким-то причинам ваши тесты подломались, пожалуйста, переканонизируйте их сами. По статистике там просто поменялся порядок в канонизации.
Если изменения действительно серьезные -- приходите в [DEVTOOLSSUPPORT](https://st.yandex-team.ru/createTicket?queue=DEVTOOLSSUPPORT) / пишите в телеграм / призывайте в тикеты, будем разбираться.
```
Changes:
[libc++] Don't try to provide source_location on AppleClang 1403
[release/16.x][libc++] Revert the bitset sort optimization
[libc++] Avoid ODR violations in __exception_guard
[libc++][ranges] Fix incorrect integer typedef in `elements_view` test.
[libc++][format] Fix a missing include in tests.
[libc++][format] Fixes invalid usage of m type.
[libc++][format] Fix floating point formatting.
[libc++] Fix ranges::binary_search() returning true for cases where the element is not in the range
[libc++] Temporarily not use compiler intrinsics for some type traits in Objective-C++ mode.
[libc++][ranges] move all range iterators back in class
[libcxx][ranges] revert join_view::iterator and sentinel to be in-class
[libc++] Add FTM for views::as_rvalue
[libc++] Fix bug in allocate_shared_for_overwrite
[libc++] fix `shared_ptr`'s incorrect constraints
[libc++] In tests, use `abort` to terminate upon an error.
[libc++] Guard the fix to CityHash behind ABI v2
[libc++][format] Fixes constexpr validation.
[libc++] Remove use of internal glibc macros to determine if c8rtomb() and mbrtoc8() are present.
[libc++] Fixes the Clang modular build.
[libc++][ranges] Temporarily mark `ranges::join_view` as experimental.
libcxx: Don't apply ABI tags to extern "C" fns
[libc++] Introduce a compile-time mechanism to override __libcpp_verbose_abort
[libc++][format] Fixes usage of contiguous ranges.
[libc++][doc] Updates format status.
[libc++][ranges] implement `std::ranges::split_view`
[libc++] implement P1020R1 P1973R1 make_unique[shared]_for_overwrite
[libc++] Improve binary size when using __transaction
[libc++] Rename take_while_view::__sentinel to __take_while_view_sentinel
[libc++] Granularize <type_traits> includes in <bit>, <numbers> and <coroutine>
[libc++] Implement P1413R3 (Deprecate std::aligned_storage and std::aligned_union)
[libc++] Add FreeBSD XFAILs in preparation for CI
[libc++] add FreeBSD atomic wait support
[libc++][format] range-default-formatter for set.
[libc++] Move iota_view::iterator and sentinel out of iota_view
[libc++] Enable clang-tidy from the buildkite pipeline instead of hard-coding it in run-buildbot
[libc++] Enable segmented iterator optimizations for join_view::iterator
[libc++] Mark LWG3349 as complete
[libc++] Remove old CI configurations and update the supported compiler versions
[libc++] Implement P2446R2 (views::as_rvalue)
[libc++][format] range-default-formatter for map
[libc++][format] Adds formatter std::vector<bool>.
[libc++][format] Adds container adaptor formatters.
[libc++][format] Implements range_formatter
[libc++][format] Adds new test macros.
[libc++][ranges] Remove a leftover include version control markers in Cxx20Papers.csv
[libc++][ranges] Mark completed Ranges papers and issues as done, bump version macro
[libc++] Add ALLOW_RETRIES to a few flaky tests
[SystemZ][z/OS] Fix cityhash lit for EBCDIC
[libc++] Mark std::pmr virtual functions as _LIBCPP_HIDE_FROM_ABI_VIRTUAL
[libc++] Remove <type_traits> includes from <atomic> and <ratio>
[libcxx] Add missing includes
[libc++] allow redefined macro in non_trivial_copy_move_ABI test
[libc++][ranges] implement `std::views::elements_view`
[libc++] Add [[clang::lifetimebound]] attribute to std::forward and friends
Reapply "[libc++][ranges]Refactor `copy{,_backward}` and `move{,_backward}`"
[libc++] Add clang-tidy to the list of possible substitutions for %{clang-tidy}
[libc++] Add missing includes in move_iterator.h
[libc++] Make pmr::monotonic_buffer_resource bump down
[libc++] Add [[nodiscard]] extensions in <math.h>
[libc++] Fix ranges::uninitialized_move{, _n} for move-only types
[libc++][ranges] Fix incorrect integer type in `view_interface` tests.
[libc++] Hold mutex lock while notify_all is called at notify_all_at_thread_exit
[Libcxx] Add <source_location> header.
[libc++] Rename transform_view::{__iterator, __sentinel} to __transform_view_{iterator, sentinel}
[libc++] Add FreeBSD exceptions.nonew ABI list
[libc++][format] Fixes escaping string literals.
[libc++] Use _LIBCPP_HIDE_FROM_ABI_VIRTUAL instead of _LIBCPP_INLINE_VISIBILITY attribute on virtual function
[libc++][test] Move `common_input_iterator` to `test_iterators.h`
[libc++][utils] Remove unused import in `run.py`
[libc++] Remove warning for `LIBCXX_SYSROOT`, `LIBCXX_TARGET_TRIPLE`, and `LIBCXX_GCC_TOOLCHAIN`
[libc++] Fix aligned_alloc usage for Android
[libc++] Use %{clang-query} when calling clang-query
[libc++] Add missing include in __format/unicode.h
[libc++] Remove HIDE_FROM_ABI from virtual functions
[libc++] Fix transitive includes list for C++23
[libc++] Add _LIBCPP_HIDE_FROM_ABI to __constexpr_logb and __constexpr_scalbn
[libc++] Granularize <bit> and remove <__bits>
[libc++] [C++20] [P0415] Constexpr for std::complex.
libc++: bring back the unsigned in the return type in wcstoull_l
[libc++][CI] Improves clang-(tidy|query) selection.
[libc++] Granularize <type_traits> includes in <iterator>
[libc++] Implement constexpr {isfinite, isinf, isnan, isnormal}
[libc++][chrono] Add calendar type formatters.
[libc++] LWG3738 Validates a missing precondition.
[libc++] LWG3745 noexcept for atomic_wait.
[libc++] Granularize <type_traits> includes in <compare>
std::sort: add BlockQuickSort partitioning algorithm for arithmetic types
[libc++] Granularize <type_traits> includes in <utility>
[libc++][format] Removes test redundancy.
[libc++][format] Adds formatter for tuple and pair
[libc++] Use aligned_alloc instead of posix_memalign for C++17
[libc++] Rename __tuple to __tuple_dir to avoid file collision
[libc++] Add FreeBSD ABI list
[libc++] Adds __cpp_lib_constexpr_algorithms to utility.
[libc++] Granularize <type_traits> includes in <concepts
[libc++][format] Renames __null_sentinel.
Implementstd::ranges::view_interface::size returns a signed type
[libc++] Implement P1169R4 (static operator())
[libc++] Implement `std::expected` P0323R12
[libc++][Android] Disable pbump2gig for Android
[libc++][Android] Android/Bionic headers don't work with modules yet
[libc++][math.h] Add double overloads
[libc++] Move filter_view::iterator and sentinel out of filter_view
[libc++] Implement P0339R6 (polymorphic_allocator<> as a vocabulary type)
[libc++][format] Adds range-default-formatter.
[libc++][Android] Rename user NS to User to avoid conflict with struct
[libc++] Fix memory leaks when throwing inside std::vector constructors
```
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/__algorithm/move.h')
-rw-r--r-- | contrib/libs/cxxsupp/libcxx/include/__algorithm/move.h | 175 |
1 files changed, 93 insertions, 82 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/move.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/move.h index e2f8b22800..ac95bda7b6 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/move.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/move.h @@ -9,111 +9,122 @@ #ifndef _LIBCPP___ALGORITHM_MOVE_H #define _LIBCPP___ALGORITHM_MOVE_H +#include <__algorithm/copy_move_common.h> #include <__algorithm/iterator_operations.h> -#include <__algorithm/unwrap_iter.h> +#include <__algorithm/min.h> #include <__config> -#include <__iterator/iterator_traits.h> -#include <__iterator/reverse_iterator.h> +#include <__iterator/segmented_iterator.h> +#include <__type_traits/common_type.h> +#include <__type_traits/is_copy_constructible.h> #include <__utility/move.h> #include <__utility/pair.h> -#include <cstring> -#include <type_traits> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif -_LIBCPP_BEGIN_NAMESPACE_STD +_LIBCPP_PUSH_MACROS +#include <__undef_macros> -// move +_LIBCPP_BEGIN_NAMESPACE_STD template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 -pair<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __result) { - while (__first != __last) { - *__result = _IterOps<_AlgPolicy>::__iter_move(__first); - ++__first; - ++__result; +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> +__move(_InIter __first, _Sent __last, _OutIter __result); + +template <class _AlgPolicy> +struct __move_loop { + template <class _InIter, class _Sent, class _OutIter> + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> + operator()(_InIter __first, _Sent __last, _OutIter __result) const { + while (__first != __last) { + *__result = _IterOps<_AlgPolicy>::__iter_move(__first); + ++__first; + ++__result; + } + return std::make_pair(std::move(__first), std::move(__result)); } - return std::make_pair(std::move(__first), std::move(__result)); -} - -template <class _AlgPolicy, - class _InType, - class _OutType, - class = __enable_if_t<is_same<__remove_const_t<_InType>, _OutType>::value - && is_trivially_move_assignable<_OutType>::value> > -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 -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<_AlgPolicy, _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> -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 _AlgPolicy, - class _InIter, - class _OutIter, - __enable_if_t<is_same<__remove_const_t<typename iterator_traits<_InIter>::value_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_SINCE_CXX17 -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<_AlgPolicy>(__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 _OutIter, __enable_if_t<__is_segmented_iterator<_InIter>::value, int> = 0> + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> + operator()(_InIter __first, _InIter __last, _OutIter __result) const { + using _Traits = __segmented_iterator_traits<_InIter>; + auto __sfirst = _Traits::__segment(__first); + auto __slast = _Traits::__segment(__last); + if (__sfirst == __slast) { + auto __iters = std::__move<_AlgPolicy>(_Traits::__local(__first), _Traits::__local(__last), std::move(__result)); + return std::make_pair(__last, std::move(__iters.second)); + } + + __result = std::__move<_AlgPolicy>(_Traits::__local(__first), _Traits::__end(__sfirst), std::move(__result)).second; + ++__sfirst; + while (__sfirst != __slast) { + __result = + std::__move<_AlgPolicy>(_Traits::__begin(__sfirst), _Traits::__end(__sfirst), std::move(__result)).second; + ++__sfirst; + } + __result = + std::__move<_AlgPolicy>(_Traits::__begin(__sfirst), _Traits::__local(__last), std::move(__result)).second; + return std::make_pair(__last, std::move(__result)); + } -template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter> -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 -__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<_AlgPolicy>( - 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 _OutIter, + __enable_if_t<__is_cpp17_random_access_iterator<_InIter>::value && + !__is_segmented_iterator<_InIter>::value && __is_segmented_iterator<_OutIter>::value, + int> = 0> + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> + operator()(_InIter __first, _InIter __last, _OutIter __result) { + using _Traits = __segmented_iterator_traits<_OutIter>; + using _DiffT = typename common_type<__iter_diff_t<_InIter>, __iter_diff_t<_OutIter> >::type; + + if (__first == __last) + return std::make_pair(std::move(__first), std::move(__result)); + + auto __local_first = _Traits::__local(__result); + auto __segment_iterator = _Traits::__segment(__result); + while (true) { + auto __local_last = _Traits::__end(__segment_iterator); + auto __size = std::min<_DiffT>(__local_last - __local_first, __last - __first); + auto __iters = std::__move<_AlgPolicy>(__first, __first + __size, __local_first); + __first = std::move(__iters.first); + + if (__first == __last) + return std::make_pair(std::move(__first), _Traits::__compose(__segment_iterator, std::move(__iters.second))); + + __local_first = _Traits::__begin(++__segment_iterator); + } + } +}; + +struct __move_trivial { + // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer. + template <class _In, class _Out, + __enable_if_t<__can_lower_move_assignment_to_memmove<_In, _Out>::value, int> = 0> + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*> + operator()(_In* __first, _In* __last, _Out* __result) const { + return std::__copy_trivial_impl(__first, __last, __result); + } +}; template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter> -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 -__enable_if_t<!is_copy_constructible<_InIter>::value - || !is_copy_constructible<_Sent>::value - || !is_copy_constructible<_OutIter>::value, pair<_InIter, _OutIter> > +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> __move(_InIter __first, _Sent __last, _OutIter __result) { - return std::__move_impl<_AlgPolicy>(std::move(__first), std::move(__last), std::move(__result)); + return std::__dispatch_copy_or_move<_AlgPolicy, __move_loop<_AlgPolicy>, __move_trivial>( + std::move(__first), std::move(__last), std::move(__result)); } template <class _InputIterator, class _OutputIterator> -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 -_OutputIterator move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { - return std::__move<_ClassicAlgPolicy>(__first, __last, __result).second; +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator +move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { + static_assert(is_copy_constructible<_InputIterator>::value, "Iterators has to be copy constructible."); + static_assert(is_copy_constructible<_OutputIterator>::value, "The output iterator has to be copy constructible."); + + return std::__move<_ClassicAlgPolicy>(std::move(__first), std::move(__last), std::move(__result)).second; } _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_MOVE_H |