26#ifndef MYSQL_HARNESS_STDX_SPAN_INCLUDED
27#define MYSQL_HARNESS_STDX_SPAN_INCLUDED
46 std::numeric_limits<std::size_t>::max();
48template <
class T, std::
size_t Extent = dynamic_extent>
52template <
class C,
class =
void>
56struct has_data<C,
std::void_t<decltype(std::data(std::declval<C>()))>>
59template <
class C,
class =
void>
63struct has_size<C,
std::void_t<decltype(std::size(std::declval<C>()))>>
68template <
class T,
class =
void>
71template <
class T,
size_t Extend>
79template <
class T,
class =
void>
82template <
class T, std::
size_t Extend>
96template <
class C,
class E,
class =
void>
99template <
class C,
class E>
101 C, E,
std::void_t<decltype(std::data(std::declval<C>()))>>
102 : std::is_convertible<
103 std::remove_pointer_t<decltype(std::data(std::declval<C &>()))> (*)[],
115template <
class R,
class E>
117 : std::bool_constant<is_contiguous_range<R>::value &&
118 is_sized_range<R>::value &&
119 !is_span<R>::value &&
120 !is_std_array<R>::value &&
121 !std::is_array_v<stdx::remove_cvref_t<R>> &&
122 is_compatible_element<R, E>::value> {};
124template <
class From,
class To>
214 return !(*
this == other);
224 return (other < *
this);
229 return !(*
this < other);
234 return !(*other < *
this);
241template <
class T,
size_t Extent>
243 static constexpr size_t size =
sizeof(T) * Extent;
251template <
size_t Extent,
size_t Offset,
size_t Count>
253 static constexpr size_t size = Count;
256template <
size_t Extent,
size_t Offset>
264template <
class T, std::
size_t Extent>
282 static constexpr const size_t extent = Extent;
303 std::enable_if_t<detail::is_compatible_range<Range, element_type>::value,
305 constexpr span(Range &cont) noexcept
306 :
data_(std::data(cont)),
size_(std::size(cont)) {}
311 template <
class Range, std::enable_if_t<std::is_const_v<element_type> &&
312 detail::is_compatible_range<
313 Range, element_type>::value,
321 template <std::size_t
N,
322 std::enable_if_t<extent == dynamic_extent || extent == N, int> = 0>
329 template <
class U, std::size_t
N,
333 constexpr span(std::array<U, N> &arr) noexcept
334 :
data_(std::data(arr)),
size_(std::size(arr)) {}
336 template <
class U, std::size_t
N,
340 constexpr span(
const std::array<U, N> &arr) noexcept
341 :
data_(std::data(arr)),
size_(std::size(arr)) {}
344 constexpr span(
const span &other)
noexcept =
default;
356 template <
std::
size_t Count>
358 static_assert(Count <= Extent);
360 assert(Count <=
size());
362 return {
data(), Count};
381 template <std::
size_t Count>
384 static_assert(Count <= Extent);
387 assert(Count <=
size());
389 return {
data() + (
size() - Count), Count};
410 template <std::
size_t Offset, std::
size_t Count = dynamic_extent>
414 static_assert(Offset <= Extent);
417 assert(Offset <=
size());
420 return {
data() + Offset,
size() - Offset};
422 assert(Count <=
size() - Offset);
425 static_assert(Count <= Extent);
426 static_assert(Count <= Extent - Offset);
430 return {
data() + Offset, Count};
442 assert(offset <=
size());
445 return {
data() + offset,
size() - offset};
459 assert(idx <
size());
461 return *(
data() + idx);
470 [[nodiscard]]
constexpr bool empty() const noexcept {
return size() == 0; }
536template <
class Container>
539template <
class Container>
547template <
class T, std::
size_t N>
550 return {
reinterpret_cast<const std::byte *
>(spn.data()), spn.size_bytes()};
556template <
class T, std::size_t
N,
557 std::enable_if_t<!std::is_const_v<T>,
int> = 0>
560 return {
reinterpret_cast<std::byte *
>(spn.data()), spn.size_bytes()};
constexpr bool operator>(const iterator &other) const
Definition: span.h:223
constexpr bool operator==(const iterator &other) const
Definition: span.h:208
constexpr iterator & operator+=(difference_type n)
Definition: span.h:142
constexpr bool operator<=(const iterator &other) const
Definition: span.h:233
typename T::pointer pointer
Definition: span.h:135
typename T::reference reference
Definition: span.h:134
std::random_access_iterator_tag iterator_category
Definition: span.h:133
typename T::difference_type difference_type
Definition: span.h:137
constexpr iterator & operator--()
Definition: span.h:181
constexpr reference operator*()
Definition: span.h:202
constexpr bool operator<(const iterator &other) const
Definition: span.h:218
pointer data_
Definition: span.h:238
constexpr reference operator[](difference_type n)
Definition: span.h:205
constexpr bool operator!=(const iterator &other) const
Definition: span.h:213
constexpr bool operator>=(const iterator &other) const
Definition: span.h:228
constexpr iterator operator--(int)
Definition: span.h:188
constexpr iterator operator+(difference_type n)
Definition: span.h:149
constexpr iterator(pointer data)
Definition: span.h:139
constexpr iterator & operator-=(difference_type n)
Definition: span.h:158
constexpr iterator & operator++()
Definition: span.h:174
typename T::value_type value_type
Definition: span.h:136
constexpr difference_type operator-(const iterator &other)
Definition: span.h:197
constexpr iterator operator-(difference_type n)
Definition: span.h:165
constexpr size_type size() const noexcept
get size in elements.
Definition: span.h:480
constexpr iterator end() const noexcept
iterator past the last element.
Definition: span.h:519
constexpr span< element_type, Count > last() const
create a span of the last Count elements.
Definition: span.h:382
std::ptrdiff_t difference_type
Definition: span.h:271
constexpr span(const std::array< U, N > &arr) noexcept
Definition: span.h:340
const T * const_pointer
Definition: span.h:274
constexpr span(const span &other) noexcept=default
std::reverse_iterator< iterator > reverse_iterator
Definition: span.h:280
std::size_t size_type
Definition: span.h:270
constexpr span(pointer ptr, size_type count)
construct a span from pointer and size
Definition: span.h:296
constexpr reverse_iterator rend() const noexcept
Definition: span.h:525
constexpr iterator begin() const noexcept
iterator to the first element.
Definition: span.h:514
constexpr span< element_type, dynamic_extent > first(size_type count) const
create a span of the first Count elements.
Definition: span.h:370
T element_type
Definition: span.h:267
constexpr span & operator=(const span &other) noexcept=default
const T & const_reference
Definition: span.h:277
size_type size_
Definition: span.h:531
constexpr span< element_type, detail::extent_size< Extent, Offset, Count >::size > subspan() const
create a span of the Count elements, starting at offset.
Definition: span.h:412
static constexpr const size_t extent
Definition: span.h:282
constexpr span(stdx::type_identity_t< element_type >(&arr)[N]) noexcept
construct a span from C-array.
Definition: span.h:323
constexpr reference operator[](size_type idx) const
returns a ref to the idx-tn element in the sequence.
Definition: span.h:458
constexpr span< element_type, Count > first() const
create a span of the first Count elements.
Definition: span.h:357
constexpr pointer data() const noexcept
get the pointer the first element.
Definition: span.h:475
std::remove_cv_t< T > value_type
Definition: span.h:268
pointer data_
Definition: span.h:530
constexpr reference back() const
return a reference to the last element.
Definition: span.h:505
constexpr span< element_type, dynamic_extent > last(size_type count) const
create a span of the last Count elements.
Definition: span.h:397
constexpr span< element_type, dynamic_extent > subspan(size_type offset, size_type count=dynamic_extent) const
create a span of the Count elements, starting at offset.
Definition: span.h:440
T * pointer
Definition: span.h:273
constexpr reference front() const
return a reference to the first element.
Definition: span.h:494
constexpr bool empty() const noexcept
check if this span is empty.
Definition: span.h:470
constexpr span() noexcept
default construct.
Definition: span.h:291
T & reference
Definition: span.h:276
constexpr span(const Range &range) noexcept
construct a span from a const continous range like a vector.
Definition: span.h:315
constexpr size_type size_bytes() const noexcept
get size in bytes.
Definition: span.h:485
constexpr span(std::array< U, N > &arr) noexcept
construct a span from a std::array.
Definition: span.h:333
constexpr reverse_iterator rbegin() const noexcept
Definition: span.h:521
constexpr span(Range &cont) noexcept
construct a span from a continous range like a vector.
Definition: span.h:305
#define U
Definition: ctype-tis620.cc:75
unsigned char byte
Blob class.
Definition: common.h:151
static int count
Definition: myisam_ftdump.cc:43
std::atomic< Type > N
Definition: ut0counter.h:225
uint16_t value_type
Definition: vt100.h:184
Definition: ut0tuple.h:57
Definition: gcs_xcom_synode.h:64
span< std::byte, detail::span_size< T, N >::size > as_writable_bytes(span< T, N > spn) noexcept
get a writable view to underlying bytes of a span 'spn'.
Definition: span.h:558
typename type_identity< T >::type type_identity_t
Definition: type_traits.h:81
span< const std::byte, detail::span_size< T, N >::size > as_bytes(span< T, N > spn) noexcept
get a view to underlying bytes of a span 'spn'.
Definition: span.h:548
span(Container &) -> span< typename Container::value_type >
constexpr std::size_t dynamic_extent
Definition: span.h:45
required string type
Definition: replication_group_member_actions.proto:34
Definition: gen_lex_token.cc:149
static constexpr size_t size
Definition: span.h:253
static constexpr size_t size
Definition: span.h:243
int n
Definition: xcom_base.cc:509