MySQL 8.0.40
Source Code Documentation
stdx::span< T, Extent > Class Template Reference

#include <span.h>

Public Types

using element_type = T
 
using value_type = std::remove_cv_t< T >
 
using size_type = std::size_t
 
using difference_type = std::ptrdiff_t
 
using pointer = T *
 
using const_pointer = const T *
 
using reference = T &
 
using const_reference = const T &
 
using iterator = detail::iterator< span >
 
using reverse_iterator = std::reverse_iterator< iterator >
 

Public Member Functions

template<bool B = (Extent == 0) || (Extent == dynamic_extent), typename std::enable_if< B, int >::type = 0>
constexpr span () noexcept
 default construct. More...
 
constexpr span (pointer ptr, size_type count)
 construct a span from pointer and size More...
 
template<class Range , std::enable_if_t< detail::is_compatible_range< Range, element_type >::value, int > = 0>
constexpr span (Range &cont) noexcept
 construct a span from a continous range like a vector. More...
 
template<class Range , std::enable_if_t< std::is_const_v< element_type > &&detail::is_compatible_range< Range, element_type >::value, int > = 0>
constexpr span (const Range &range) noexcept
 construct a span from a const continous range like a vector. More...
 
template<std::size_t N, std::enable_if_t< extent==dynamic_extent||extent==N, int > = 0>
constexpr span (stdx::type_identity_t< element_type >(&arr)[N]) noexcept
 construct a span from C-array. More...
 
template<class U , std::size_t N, std::enable_if_t<(Extent==dynamic_extent||Extent==N) &&detail::is_array_convertible< U, T >::value, int > = 0>
constexpr span (std::array< U, N > &arr) noexcept
 construct a span from a std::array. More...
 
template<class U , std::size_t N, std::enable_if_t<(Extent==dynamic_extent||Extent==N) &&detail::is_array_convertible< U, T >::value, int > = 0>
constexpr span (const std::array< U, N > &arr) noexcept
 
constexpr span (const span &other) noexcept=default
 
constexpr spanoperator= (const span &other) noexcept=default
 
 ~span () noexcept=default
 
template<std::size_t Count>
constexpr span< element_type, Count > first () const
 create a span of the first Count elements. More...
 
constexpr span< element_type, dynamic_extentfirst (size_type count) const
 create a span of the first Count elements. More...
 
template<std::size_t Count>
constexpr span< element_type, Count > last () const
 create a span of the last Count elements. More...
 
constexpr span< element_type, dynamic_extentlast (size_type count) const
 create a span of the last Count elements. More...
 
template<std::size_t Offset, std::size_t Count = dynamic_extent>
constexpr span< element_type, detail::extent_size< Extent, Offset, Count >::sizesubspan () const
 create a span of the Count elements, starting at offset. More...
 
constexpr span< element_type, dynamic_extentsubspan (size_type offset, size_type count=dynamic_extent) const
 create a span of the Count elements, starting at offset. More...
 
constexpr reference operator[] (size_type idx) const
 returns a ref to the idx-tn element in the sequence. More...
 
constexpr bool empty () const noexcept
 check if this span is empty. More...
 
constexpr pointer data () const noexcept
 get the pointer the first element. More...
 
constexpr size_type size () const noexcept
 get size in elements. More...
 
constexpr size_type size_bytes () const noexcept
 get size in bytes. More...
 
constexpr reference front () const
 return a reference to the first element. More...
 
constexpr reference back () const
 return a reference to the last element. More...
 
constexpr iterator begin () const noexcept
 iterator to the first element. More...
 
constexpr iterator end () const noexcept
 iterator past the last element. More...
 
constexpr reverse_iterator rbegin () const noexcept
 
constexpr reverse_iterator rend () const noexcept
 

Static Public Attributes

static constexpr const size_t extent = Extent
 

Private Attributes

pointer data_
 
size_type size_
 

Member Typedef Documentation

◆ const_pointer

template<class T , std::size_t Extent>
using stdx::span< T, Extent >::const_pointer = const T *

◆ const_reference

template<class T , std::size_t Extent>
using stdx::span< T, Extent >::const_reference = const T &

◆ difference_type

template<class T , std::size_t Extent>
using stdx::span< T, Extent >::difference_type = std::ptrdiff_t

◆ element_type

template<class T , std::size_t Extent>
using stdx::span< T, Extent >::element_type = T

◆ iterator

template<class T , std::size_t Extent>
using stdx::span< T, Extent >::iterator = detail::iterator<span>

◆ pointer

template<class T , std::size_t Extent>
using stdx::span< T, Extent >::pointer = T *

◆ reference

template<class T , std::size_t Extent>
using stdx::span< T, Extent >::reference = T &

◆ reverse_iterator

template<class T , std::size_t Extent>
using stdx::span< T, Extent >::reverse_iterator = std::reverse_iterator<iterator>

◆ size_type

template<class T , std::size_t Extent>
using stdx::span< T, Extent >::size_type = std::size_t

◆ value_type

template<class T , std::size_t Extent>
using stdx::span< T, Extent >::value_type = std::remove_cv_t<T>

Constructor & Destructor Documentation

◆ span() [1/8]

template<class T , std::size_t Extent>
template<bool B = (Extent == 0) || (Extent == dynamic_extent), typename std::enable_if< B, int >::type = 0>
constexpr stdx::span< T, Extent >::span ( )
inlineconstexprnoexcept

default construct.

only enabled if Extent is 0 or dynamic.

◆ span() [2/8]

template<class T , std::size_t Extent>
constexpr stdx::span< T, Extent >::span ( pointer  ptr,
size_type  count 
)
inlineconstexpr

construct a span from pointer and size

◆ span() [3/8]

template<class T , std::size_t Extent>
template<class Range , std::enable_if_t< detail::is_compatible_range< Range, element_type >::value, int > = 0>
constexpr stdx::span< T, Extent >::span ( Range &  cont)
inlineconstexprnoexcept

construct a span from a continous range like a vector.

◆ span() [4/8]

template<class T , std::size_t Extent>
template<class Range , std::enable_if_t< std::is_const_v< element_type > &&detail::is_compatible_range< Range, element_type >::value, int > = 0>
constexpr stdx::span< T, Extent >::span ( const Range &  range)
inlineconstexprnoexcept

construct a span from a const continous range like a vector.

◆ span() [5/8]

template<class T , std::size_t Extent>
template<std::size_t N, std::enable_if_t< extent==dynamic_extent||extent==N, int > = 0>
constexpr stdx::span< T, Extent >::span ( stdx::type_identity_t< element_type >(&)  arr[N])
inlineconstexprnoexcept

construct a span from C-array.

◆ span() [6/8]

template<class T , std::size_t Extent>
template<class U , std::size_t N, std::enable_if_t<(Extent==dynamic_extent||Extent==N) &&detail::is_array_convertible< U, T >::value, int > = 0>
constexpr stdx::span< T, Extent >::span ( std::array< U, N > &  arr)
inlineconstexprnoexcept

construct a span from a std::array.

◆ span() [7/8]

template<class T , std::size_t Extent>
template<class U , std::size_t N, std::enable_if_t<(Extent==dynamic_extent||Extent==N) &&detail::is_array_convertible< U, T >::value, int > = 0>
constexpr stdx::span< T, Extent >::span ( const std::array< U, N > &  arr)
inlineconstexprnoexcept

◆ span() [8/8]

template<class T , std::size_t Extent>
constexpr stdx::span< T, Extent >::span ( const span< T, Extent > &  other)
constexprdefaultnoexcept

◆ ~span()

template<class T , std::size_t Extent>
stdx::span< T, Extent >::~span ( )
defaultnoexcept

Member Function Documentation

◆ back()

template<class T , std::size_t Extent>
constexpr reference stdx::span< T, Extent >::back ( ) const
inlineconstexpr

return a reference to the last element.

The behaviour is undefined if the span is empty.

◆ begin()

template<class T , std::size_t Extent>
constexpr iterator stdx::span< T, Extent >::begin ( ) const
inlineconstexprnoexcept

iterator to the first element.

◆ data()

template<class T , std::size_t Extent>
constexpr pointer stdx::span< T, Extent >::data ( ) const
inlineconstexprnoexcept

get the pointer the first element.

◆ empty()

template<class T , std::size_t Extent>
constexpr bool stdx::span< T, Extent >::empty ( ) const
inlineconstexprnoexcept

check if this span is empty.

Return values
trueif span is empty.
falseif span is not empty.

◆ end()

template<class T , std::size_t Extent>
constexpr iterator stdx::span< T, Extent >::end ( ) const
inlineconstexprnoexcept

iterator past the last element.

◆ first() [1/2]

template<class T , std::size_t Extent>
template<std::size_t Count>
constexpr span< element_type, Count > stdx::span< T, Extent >::first ( ) const
inlineconstexpr

create a span of the first Count elements.

The behaviour is undefined if Count > size()

◆ first() [2/2]

template<class T , std::size_t Extent>
constexpr span< element_type, dynamic_extent > stdx::span< T, Extent >::first ( size_type  count) const
inlineconstexpr

create a span of the first Count elements.

The behaviour is undefined if count > size().

◆ front()

template<class T , std::size_t Extent>
constexpr reference stdx::span< T, Extent >::front ( ) const
inlineconstexpr

return a reference to the first element.

The behaviour is undefined if the span is empty.

◆ last() [1/2]

template<class T , std::size_t Extent>
template<std::size_t Count>
constexpr span< element_type, Count > stdx::span< T, Extent >::last ( ) const
inlineconstexpr

create a span of the last Count elements.

The behaviour is undefined if Count > size().

◆ last() [2/2]

template<class T , std::size_t Extent>
constexpr span< element_type, dynamic_extent > stdx::span< T, Extent >::last ( size_type  count) const
inlineconstexpr

create a span of the last Count elements.

The behaviour is undefined if count > size().

◆ operator=()

template<class T , std::size_t Extent>
constexpr span & stdx::span< T, Extent >::operator= ( const span< T, Extent > &  other)
constexprdefaultnoexcept

◆ operator[]()

template<class T , std::size_t Extent>
constexpr reference stdx::span< T, Extent >::operator[] ( size_type  idx) const
inlineconstexpr

returns a ref to the idx-tn element in the sequence.

The behaviour is undefined if idx >= size()

◆ rbegin()

template<class T , std::size_t Extent>
constexpr reverse_iterator stdx::span< T, Extent >::rbegin ( ) const
inlineconstexprnoexcept

◆ rend()

template<class T , std::size_t Extent>
constexpr reverse_iterator stdx::span< T, Extent >::rend ( ) const
inlineconstexprnoexcept

◆ size()

template<class T , std::size_t Extent>
constexpr size_type stdx::span< T, Extent >::size ( ) const
inlineconstexprnoexcept

get size in elements.

◆ size_bytes()

template<class T , std::size_t Extent>
constexpr size_type stdx::span< T, Extent >::size_bytes ( ) const
inlineconstexprnoexcept

get size in bytes.

◆ subspan() [1/2]

template<class T , std::size_t Extent>
template<std::size_t Offset, std::size_t Count = dynamic_extent>
constexpr span< element_type, detail::extent_size< Extent, Offset, Count >::size > stdx::span< T, Extent >::subspan ( ) const
inlineconstexpr

create a span of the Count elements, starting at offset.

if 'Count' is 'dynamic_extent', then up to the end of the span.

The behaviour is undefined if Offset or Count are out of range.

◆ subspan() [2/2]

template<class T , std::size_t Extent>
constexpr span< element_type, dynamic_extent > stdx::span< T, Extent >::subspan ( size_type  offset,
size_type  count = dynamic_extent 
) const
inlineconstexpr

create a span of the Count elements, starting at offset.

if 'count' is 'dynamic_extent', then up to the end of the span.

The behaviour is undefined if Count > size(), and if Offset > size().

Member Data Documentation

◆ data_

template<class T , std::size_t Extent>
pointer stdx::span< T, Extent >::data_
private

◆ extent

template<class T , std::size_t Extent>
constexpr const size_t stdx::span< T, Extent >::extent = Extent
staticconstexpr

◆ size_

template<class T , std::size_t Extent>
size_type stdx::span< T, Extent >::size_
private

The documentation for this class was generated from the following file: