aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/include/span
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/span
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/span')
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/span87
1 files changed, 37 insertions, 50 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/span b/contrib/libs/cxxsupp/libcxx/include/span
index 7950396137..ec8b1cd755 100644
--- a/contrib/libs/cxxsupp/libcxx/include/span
+++ b/contrib/libs/cxxsupp/libcxx/include/span
@@ -143,11 +143,19 @@ template<class R>
#include <__utility/forward.h>
#include <array> // for array
#include <cstddef> // for byte
-#include <iterator> // TODO: Remove this include
#include <limits>
#include <type_traits> // for remove_cv, etc
#include <version>
+// standard-mandated includes
+
+// [iterator.range]
+#include <__iterator/access.h>
+#include <__iterator/data.h>
+#include <__iterator/empty.h>
+#include <__iterator/reverse_access.h>
+#include <__iterator/size.h>
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
@@ -199,6 +207,15 @@ concept __span_compatible_range =
is_convertible_v<remove_reference_t<ranges::range_reference_t<_Range>>(*)[], _ElementType(*)[]>;
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+template <class _From, class _To>
+concept __span_array_convertible = is_convertible_v<_From(*)[], _To(*)[]>;
+
+template <class _It, class _Tp>
+concept __span_compatible_iterator = contiguous_iterator<_It> && __span_array_convertible<remove_reference_t<iter_reference_t<_It>>, _Tp>;
+
+template <class _Sentinel, class _It>
+concept __span_compatible_sentinel_for = sized_sentinel_for<_Sentinel, _It> && !is_convertible_v<_Sentinel, size_t>;
+
#if defined(_LIBCPP_ENABLE_DEBUG_MODE) || defined(_LIBCPP_ABI_SPAN_POINTER_ITERATORS)
# define _LIBCPP_SPAN_USE_POINTER_ITERATOR
#endif
@@ -225,16 +242,13 @@ public:
static constexpr size_type extent = _Extent;
// [span.cons], span constructors, copy, assignment, and destructor
- template <size_t _Sz = _Extent, enable_if_t<_Sz == 0, nullptr_t> = nullptr>
+ template <size_t _Sz = _Extent> requires(_Sz == 0)
_LIBCPP_INLINE_VISIBILITY constexpr span() noexcept : __data{nullptr} {}
constexpr span (const span&) noexcept = default;
constexpr span& operator=(const span&) noexcept = default;
- template <class _It,
- enable_if_t<contiguous_iterator<_It> &&
- is_convertible_v<remove_reference_t<iter_reference_t<_It>>(*)[], element_type (*)[]>,
- nullptr_t> = nullptr>
+ template <__span_compatible_iterator<element_type> _It>
_LIBCPP_INLINE_VISIBILITY
constexpr explicit span(_It __first, size_type __count)
: __data{_VSTD::to_address(__first)} {
@@ -242,11 +256,7 @@ public:
_LIBCPP_ASSERT(_Extent == __count, "size mismatch in span's constructor (iterator, len)");
}
- template <
- class _It, class _End,
- enable_if_t<is_convertible_v<remove_reference_t<iter_reference_t<_It> > (*)[], element_type (*)[]> &&
- contiguous_iterator<_It> && sized_sentinel_for<_End, _It> && !is_convertible_v<_End, size_t>,
- nullptr_t> = nullptr>
+ template <__span_compatible_iterator<element_type> _It, __span_compatible_sentinel_for<_It> _End>
_LIBCPP_INLINE_VISIBILITY
constexpr explicit span(_It __first, _End __last) : __data{_VSTD::to_address(__first)} {
(void)__last;
@@ -257,13 +267,12 @@ public:
_LIBCPP_INLINE_VISIBILITY constexpr span(type_identity_t<element_type> (&__arr)[_Extent]) noexcept : __data{__arr} {}
- template <class _OtherElementType,
- enable_if_t<is_convertible_v<_OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr>
+ template <__span_array_convertible<element_type> _OtherElementType>
_LIBCPP_INLINE_VISIBILITY
constexpr span(array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {}
- template <class _OtherElementType,
- enable_if_t<is_convertible_v<const _OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr>
+ template <class _OtherElementType>
+ requires __span_array_convertible<const _OtherElementType, element_type>
_LIBCPP_INLINE_VISIBILITY
constexpr span(const array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {}
@@ -288,20 +297,14 @@ public:
}
#endif
- template <class _OtherElementType>
+ template <__span_array_convertible<element_type> _OtherElementType>
_LIBCPP_INLINE_VISIBILITY
- constexpr span(const span<_OtherElementType, _Extent>& __other,
- enable_if_t<
- is_convertible_v<_OtherElementType(*)[], element_type (*)[]>,
- nullptr_t> = nullptr)
+ constexpr span(const span<_OtherElementType, _Extent>& __other)
: __data{__other.data()} {}
- template <class _OtherElementType>
+ template <__span_array_convertible<element_type> _OtherElementType>
_LIBCPP_INLINE_VISIBILITY
- constexpr explicit span(const span<_OtherElementType, dynamic_extent>& __other,
- enable_if_t<
- is_convertible_v<_OtherElementType(*)[], element_type (*)[]>,
- nullptr_t> = nullptr) noexcept
+ constexpr explicit span(const span<_OtherElementType, dynamic_extent>& __other) noexcept
: __data{__other.data()} { _LIBCPP_ASSERT(_Extent == __other.size(), "size mismatch in span's constructor (other span)"); }
@@ -412,14 +415,11 @@ public:
private:
pointer __data;
-
};
template <typename _Tp>
class _LIBCPP_TEMPLATE_VIS span<_Tp, dynamic_extent> {
-private:
-
public:
// constants and types
using element_type = _Tp;
@@ -445,19 +445,12 @@ public:
constexpr span (const span&) noexcept = default;
constexpr span& operator=(const span&) noexcept = default;
- template <class _It,
- enable_if_t<contiguous_iterator<_It> &&
- is_convertible_v<remove_reference_t<iter_reference_t<_It> > (*)[], element_type (*)[]>,
- nullptr_t> = nullptr>
+ template <__span_compatible_iterator<element_type> _It>
_LIBCPP_INLINE_VISIBILITY
constexpr span(_It __first, size_type __count)
: __data{_VSTD::to_address(__first)}, __size{__count} {}
- template <
- class _It, class _End,
- enable_if_t<is_convertible_v<remove_reference_t<iter_reference_t<_It> > (*)[], element_type (*)[]> &&
- contiguous_iterator<_It> && sized_sentinel_for<_End, _It> && !is_convertible_v<_End, size_t>,
- nullptr_t> = nullptr>
+ template <__span_compatible_iterator<element_type> _It, __span_compatible_sentinel_for<_It> _End>
_LIBCPP_INLINE_VISIBILITY
constexpr span(_It __first, _End __last)
: __data(_VSTD::to_address(__first)), __size(__last - __first) {}
@@ -466,13 +459,12 @@ public:
_LIBCPP_INLINE_VISIBILITY
constexpr span(type_identity_t<element_type> (&__arr)[_Sz]) noexcept : __data{__arr}, __size{_Sz} {}
- template <class _OtherElementType, size_t _Sz,
- enable_if_t<is_convertible_v<_OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr>
+ template <__span_array_convertible<element_type> _OtherElementType, size_t _Sz>
_LIBCPP_INLINE_VISIBILITY
constexpr span(array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {}
- template <class _OtherElementType, size_t _Sz,
- enable_if_t<is_convertible_v<const _OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr>
+ template <class _OtherElementType, size_t _Sz>
+ requires __span_array_convertible<const _OtherElementType, element_type>
_LIBCPP_INLINE_VISIBILITY
constexpr span(const array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {}
@@ -491,12 +483,9 @@ public:
constexpr span(_Range&& __r) : __data(ranges::data(__r)), __size{ranges::size(__r)} {}
#endif
- template <class _OtherElementType, size_t _OtherExtent>
+ template <__span_array_convertible<element_type> _OtherElementType, size_t _OtherExtent>
_LIBCPP_INLINE_VISIBILITY
- constexpr span(const span<_OtherElementType, _OtherExtent>& __other,
- enable_if_t<
- is_convertible_v<_OtherElementType(*)[], element_type (*)[]>,
- nullptr_t> = nullptr) noexcept
+ constexpr span(const span<_OtherElementType, _OtherExtent>& __other) noexcept
: __data{__other.data()}, __size{__other.size()} {}
// ~span() noexcept = default;
@@ -622,13 +611,11 @@ inline constexpr bool ranges::enable_view<span<_ElementType, _Extent>> = true;
template <class _Tp, size_t _Extent>
_LIBCPP_INLINE_VISIBILITY
auto as_bytes(span<_Tp, _Extent> __s) noexcept
--> decltype(__s.__as_bytes())
-{ return __s.__as_bytes(); }
+{ return __s.__as_bytes(); }
-template <class _Tp, size_t _Extent>
+template <class _Tp, size_t _Extent> requires(!is_const_v<_Tp>)
_LIBCPP_INLINE_VISIBILITY
auto as_writable_bytes(span<_Tp, _Extent> __s) noexcept
--> enable_if_t<!is_const_v<_Tp>, decltype(__s.__as_writable_bytes())>
{ return __s.__as_writable_bytes(); }
#if _LIBCPP_STD_VER > 17