25#ifndef MYSQL_HARNESS_STDX_SPAN_INCLUDED
26#define MYSQL_HARNESS_STDX_SPAN_INCLUDED
45 std::numeric_limits<std::size_t>::max();
47template <
class T, std::
size_t Extent = dynamic_extent>
51template <
class C,
class =
void>
55struct has_data<C,
std::void_t<decltype(std::data(std::declval<C>()))>>
58template <
class C,
class =
void>
62struct has_size<C,
std::void_t<decltype(std::size(std::declval<C>()))>>
67template <
class T,
class =
void>
70template <
class T,
size_t Extend>
78template <
class T,
class =
void>
81template <
class T, std::
size_t Extend>
95template <
class C,
class E,
class =
void>
98template <
class C,
class E>
100 C, E,
std::void_t<decltype(std::data(std::declval<C>()))>>
101 : std::is_convertible<
102 std::remove_pointer_t<decltype(std::data(std::declval<C &>()))> (*)[],
114template <
class R,
class E>
116 : std::bool_constant<is_contiguous_range<R>::value &&
117 is_sized_range<R>::value &&
118 !is_span<R>::value &&
119 !is_std_array<R>::value &&
120 !std::is_array_v<stdx::remove_cvref_t<R>> &&
121 is_compatible_element<R, E>::value> {};
123template <
class From,
class To>
213 return !(*
this == other);
223 return (other < *
this);
228 return !(*
this < other);
233 return !(*other < *
this);
240template <
class T,
size_t Extent>
242 static constexpr size_t size =
sizeof(T) * Extent;
250template <
size_t Extent,
size_t Offset,
size_t Count>
252 static constexpr size_t size = Count;
255template <
size_t Extent,
size_t Offset>
263template <
class T, std::
size_t Extent>
281 static constexpr const size_t extent = Extent;
302 std::enable_if_t<detail::is_compatible_range<Range, element_type>::value,
304 constexpr span(Range &cont) noexcept
305 :
data_(std::data(cont)),
size_(std::size(cont)) {}
310 template <
class Range, std::enable_if_t<std::is_const_v<element_type> &&
311 detail::is_compatible_range<
312 Range, element_type>::value,
320 template <std::size_t
N,
321 std::enable_if_t<extent == dynamic_extent || extent == N, int> = 0>
328 template <
class U, std::size_t
N,
332 constexpr span(std::array<U, N> &arr) noexcept
333 :
data_(std::data(arr)),
size_(std::size(arr)) {}
335 template <
class U, std::size_t
N,
339 constexpr span(
const std::array<U, N> &arr) noexcept
340 :
data_(std::data(arr)),
size_(std::size(arr)) {}
343 constexpr span(
const span &other)
noexcept =
default;
355 template <
std::
size_t Count>
357 static_assert(Count <= Extent);
359 assert(Count <=
size());
361 return {
data(), Count};
380 template <std::
size_t Count>
383 static_assert(Count <= Extent);
386 assert(Count <=
size());
388 return {
data() + (
size() - Count), Count};
409 template <std::
size_t Offset, std::
size_t Count = dynamic_extent>
413 static_assert(Offset <= Extent);
416 assert(Offset <=
size());
419 return {
data() + Offset,
size() - Offset};
421 assert(Count <=
size() - Offset);
424 static_assert(Count <= Extent);
425 static_assert(Count <= Extent - Offset);
429 return {
data() + Offset, Count};
441 assert(offset <=
size());
444 return {
data() + offset,
size() - offset};
458 assert(idx <
size());
460 return *(
data() + idx);
469 [[nodiscard]]
constexpr bool empty() const noexcept {
return size() == 0; }
535template <
class Container>
538template <
class Container>
546template <
class T, std::
size_t N>
549 return {
reinterpret_cast<const std::byte *
>(spn.data()), spn.size_bytes()};
555template <
class T, std::size_t
N,
556 std::enable_if_t<!std::is_const_v<T>,
int> = 0>
559 return {
reinterpret_cast<std::byte *
>(spn.data()), spn.size_bytes()};
constexpr bool operator>(const iterator &other) const
Definition: span.h:222
constexpr bool operator==(const iterator &other) const
Definition: span.h:207
constexpr iterator & operator+=(difference_type n)
Definition: span.h:141
constexpr bool operator<=(const iterator &other) const
Definition: span.h:232
typename T::pointer pointer
Definition: span.h:134
typename T::reference reference
Definition: span.h:133
std::random_access_iterator_tag iterator_category
Definition: span.h:132
typename T::difference_type difference_type
Definition: span.h:136
constexpr iterator & operator--()
Definition: span.h:180
constexpr reference operator*()
Definition: span.h:201
constexpr bool operator<(const iterator &other) const
Definition: span.h:217
pointer data_
Definition: span.h:237
constexpr reference operator[](difference_type n)
Definition: span.h:204
constexpr bool operator!=(const iterator &other) const
Definition: span.h:212
constexpr bool operator>=(const iterator &other) const
Definition: span.h:227
constexpr iterator operator--(int)
Definition: span.h:187
constexpr iterator operator+(difference_type n)
Definition: span.h:148
constexpr iterator(pointer data)
Definition: span.h:138
constexpr iterator & operator-=(difference_type n)
Definition: span.h:157
constexpr iterator & operator++()
Definition: span.h:173
typename T::value_type value_type
Definition: span.h:135
constexpr difference_type operator-(const iterator &other)
Definition: span.h:196
constexpr iterator operator-(difference_type n)
Definition: span.h:164
constexpr size_type size() const noexcept
get size in elements.
Definition: span.h:479
constexpr iterator end() const noexcept
iterator past the last element.
Definition: span.h:518
constexpr span< element_type, Count > last() const
create a span of the last Count elements.
Definition: span.h:381
std::ptrdiff_t difference_type
Definition: span.h:270
constexpr span(const std::array< U, N > &arr) noexcept
Definition: span.h:339
const T * const_pointer
Definition: span.h:273
constexpr span(const span &other) noexcept=default
std::reverse_iterator< iterator > reverse_iterator
Definition: span.h:279
std::size_t size_type
Definition: span.h:269
constexpr span(pointer ptr, size_type count)
construct a span from pointer and size
Definition: span.h:295
constexpr reverse_iterator rend() const noexcept
Definition: span.h:524
constexpr iterator begin() const noexcept
iterator to the first element.
Definition: span.h:513
constexpr span< element_type, dynamic_extent > first(size_type count) const
create a span of the first Count elements.
Definition: span.h:369
T element_type
Definition: span.h:266
constexpr span & operator=(const span &other) noexcept=default
const T & const_reference
Definition: span.h:276
size_type size_
Definition: span.h:530
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:411
static constexpr const size_t extent
Definition: span.h:281
constexpr span(stdx::type_identity_t< element_type >(&arr)[N]) noexcept
construct a span from C-array.
Definition: span.h:322
constexpr reference operator[](size_type idx) const
returns a ref to the idx-tn element in the sequence.
Definition: span.h:457
constexpr span< element_type, Count > first() const
create a span of the first Count elements.
Definition: span.h:356
constexpr pointer data() const noexcept
get the pointer the first element.
Definition: span.h:474
std::remove_cv_t< T > value_type
Definition: span.h:267
pointer data_
Definition: span.h:529
constexpr reference back() const
return a reference to the last element.
Definition: span.h:504
constexpr span< element_type, dynamic_extent > last(size_type count) const
create a span of the last Count elements.
Definition: span.h:396
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:439
T * pointer
Definition: span.h:272
constexpr reference front() const
return a reference to the first element.
Definition: span.h:493
constexpr bool empty() const noexcept
check if this span is empty.
Definition: span.h:469
constexpr span() noexcept
default construct.
Definition: span.h:290
T & reference
Definition: span.h:275
constexpr span(const Range &range) noexcept
construct a span from a const continous range like a vector.
Definition: span.h:314
constexpr size_type size_bytes() const noexcept
get size in bytes.
Definition: span.h:484
constexpr span(std::array< U, N > &arr) noexcept
construct a span from a std::array.
Definition: span.h:332
constexpr reverse_iterator rbegin() const noexcept
Definition: span.h:520
constexpr span(Range &cont) noexcept
construct a span from a continous range like a vector.
Definition: span.h:304
#define U
Definition: ctype-tis620.cc:73
unsigned char byte
Blob class.
Definition: common.h:150
static int count
Definition: myisam_ftdump.cc:44
std::atomic< Type > N
Definition: ut0counter.h:224
uint16_t value_type
Definition: vt100.h:183
Definition: ut0tuple.h:56
Definition: varlen_sort.h:183
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:557
typename type_identity< T >::type type_identity_t
Definition: type_traits.h:80
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:547
span(Container &) -> span< typename Container::value_type >
constexpr std::size_t dynamic_extent
Definition: span.h:44
required string type
Definition: replication_group_member_actions.proto:33
Definition: gen_lex_token.cc:148
static constexpr size_t size
Definition: span.h:252
static constexpr size_t size
Definition: span.h:242
int n
Definition: xcom_base.cc:508