Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
arene::base::span< T, Extent > Class Template Reference

A backport of std::span for C++14. Provides a view over a contiguous range of elements of type T. More...

Inheritance diagram for arene::base::span< T, Extent >:
Inheritance graph

Public Types

using const_iterator = detail::wrapped_iterator<const_pointer, span_detail::span_iter_passkey>
 The type of an iterator into a const view of the data viewed by the span.
 
using const_pointer = T const*
 The type of pointers to const elements of the span.
 
using const_reference = T const&
 The type of references to const elements of the span.
 
using const_reverse_iterator = ::arene::base::reverse_iterator<const_iterator>
 The type of an iterator into a const and reversed view of the data viewed by the span.
 
using difference_type = typename iterator::difference_type
 The type used for obtaining differences between iterators of the span.
 
using element_type = T
 The type of the elements of the span.
 
using iterator = detail::wrapped_iterator<pointer, span_detail::span_iter_passkey>
 The type of an iterator into the data viewed by the span.
 
using pointer = T*
 The type of pointers to elements of the span.
 
using reference = T&
 The type of references to elements of the span.
 
using reverse_iterator = ::arene::base::reverse_iterator<iterator>
 The type of an iterator into a reversed view of the data viewed by the span.
 
using size_type = std::size_t
 The type of the size of the span.
 
using value_type = arene::base::remove_cvref_t<T>
 The type of the elements of the span without const or volatile qualification.
 

Public Member Functions

constexpr span () noexcept=default
 Default-constructs an empty span. Only exists if Extent==dynamic_extent or Extent==0.
 
template<template< typename U, std::size_t N > class ArrayLikeT, typename U, std::size_t N, constraints< std::enable_if_t< span_detail::has_member_data_v< ArrayLikeT< U, N > > >, std::enable_if_t< span_detail::has_tuple_size_v< ArrayLikeT< U, N > > >, std::enable_if_t< std::tuple_size< ArrayLikeT< U, N > >::value==N >, std::enable_if_t< arene::base::is_array_convertible_v< U, T > >, std::enable_if_t< is_valid_source_extent_v< N > > > = nullptr>
constexpr span (ArrayLikeT< U, N > &&array) noexcept
 Constructor from an rvalue std::array -like type.
 
template<template< typename U, std::size_t N > class ArrayLikeT, typename U, std::size_t N, constraints< std::enable_if_t< span_detail::has_member_data_v< ArrayLikeT< U, N > > >, std::enable_if_t< span_detail::has_tuple_size_v< ArrayLikeT< U, N > > >, std::enable_if_t< std::tuple_size< ArrayLikeT< U, N > >::value==N >, std::enable_if_t< arene::base::is_array_convertible_v< U, T > >, std::enable_if_t< is_valid_source_extent_v< N > > > = nullptr>
constexpr span (ArrayLikeT< U, N > &array) noexcept
 Constructor from a std::array.
 
template<template< typename U, std::size_t N > class ArrayLikeT, typename U, std::size_t N, constraints< std::enable_if_t< span_detail::has_member_data_v< ArrayLikeT< U, N > > >, std::enable_if_t< span_detail::has_tuple_size_v< ArrayLikeT< U, N > > >, std::enable_if_t< std::tuple_size< ArrayLikeT< U, N > >::value==N >, std::enable_if_t< std::is_const< T >::value &&arene::base::is_array_convertible_v< U, T > >, std::enable_if_t< is_valid_source_extent_v< N > > > = nullptr>
constexpr span (ArrayLikeT< U, N > const &&array) noexcept
 Constructor from an const rvalue std::array -like type.
 
template<template< typename U, std::size_t N > class ArrayLikeT, typename U, std::size_t N, constraints< std::enable_if_t< span_detail::has_member_data_v< ArrayLikeT< U, N > > >, std::enable_if_t< span_detail::has_tuple_size_v< ArrayLikeT< U, N > > >, std::enable_if_t< std::tuple_size< ArrayLikeT< U, N > >::value==N >, std::enable_if_t< std::is_const< T >::value &&arene::base::is_array_convertible_v< U, T > >, std::enable_if_t< is_valid_source_extent_v< N > > > = nullptr>
constexpr span (ArrayLikeT< U, N > const &array) noexcept
 Constructor from a const std::array -like type.
 
template<typename Container, constraints< std::enable_if_t< !span_detail::has_tuple_size_v< arene::base::remove_cvref_t< Container > > &&span_detail::is_dynamic_extent(Extent)>, std::enable_if_t< arene::base::is_array_convertible_v< arene::base::remove_reference_t< >, T > > > = nullptr>
constexpr span (Container &&source) noexcept
 Constructor from a container of T with contiguous elements.
 
template<typename Container, constraints< std::enable_if_t< !span_detail::has_tuple_size_v< arene::base::remove_cvref_t< Container > > &&!span_detail::is_dynamic_extent(Extent)>, std::enable_if_t< arene::base::is_array_convertible_v< arene::base::remove_reference_t< >, T > > > = nullptr>
constexpr span (Container &&source) noexcept
 Constructor from a container of T with contiguous elements.
 
constexpr span (span &&other)=default
 default move constructor
 
constexpr span (span const &other)=default
 default copy constructor
 
template<typename U, std::size_t OtherExtent, constraints< std::enable_if_t< !span_detail::is_dynamic_extent(Extent) &&!span_detail::is_dynamic_extent(OtherExtent) &&Extent !=OtherExtent > > = nullptr>
constexpr span (span< U, OtherExtent > &&other) noexcept=delete
 Disable construction of fixed size spans from other spans of mismatched size.
 
template<typename U, std::size_t OtherExtent, constraints< std::enable_if_t< arene::base::is_array_convertible_v< U, T > >, std::enable_if_t< is_valid_source_extent_v< OtherExtent > > > = nullptr>
constexpr span (span< U, OtherExtent > const &other) noexcept
 Constructor from another span<U,OtherExtent> when Extent is "no more restrictive" then OtherExtent.
 
template<typename U, std::size_t OtherExtent, constraints< std::enable_if_t< arene::base::is_array_convertible_v< U, T > >, std::enable_if_t<(!span_detail::is_dynamic_extent(Extent)) &&span_detail::is_dynamic_extent(OtherExtent)> > = nullptr>
constexpr span (span< U, OtherExtent > const &other) noexcept
 Constructor from span<U,dynamic_extent> when Extent is not dynamic_extent .
 
template<std::size_t N, constraints< std::enable_if_t< is_valid_source_extent_v< N > > > = nullptr>
constexpr span (T(&array)[N]) noexcept
 Constructor from a c-array.
 
template<typename U, constraints< std::enable_if_t< arene::base::is_array_convertible_v< U, T > > > = nullptr>
constexpr span (U *data_pointer, std::size_t data_size) noexcept
 Construct with the specified data and size. Prevents implicit derived-to-base pointer conversions on the supplied data argument.
 
 ~span ()=default
 default destructor
 
ARENE_NODISCARD constexpr auto back () const noexcept -> T &
 Access the last element in the span.
 
ARENE_NODISCARD constexpr auto begin () const noexcept -> iterator
 Obtain an iterator to the beginning of the data viewed by the span.
 
ARENE_NODISCARD constexpr auto cbegin () const noexcept -> const_iterator
 Obtain a const_iterator to the beginning of the data viewed by the span.
 
ARENE_NODISCARD constexpr auto cend () const noexcept -> const_iterator
 Obtain a const_iterator to the one-past-the-end of the data viewed by the span.
 
ARENE_NODISCARD constexpr auto crbegin () const noexcept -> const_reverse_iterator
 Obtain a const_iterator to the beginning of a reversed view of the data in the span.
 
ARENE_NODISCARD constexpr auto crend () const noexcept -> const_reverse_iterator
 Obtain a const iterator to one-past-the-end of a reversed view of the data in the span.
 
ARENE_NODISCARD constexpr auto data () const noexcept -> T *
 Accessor to the underlying data as a raw pointer.
 
ARENE_NODISCARD constexpr auto empty () const noexcept -> bool
 Predicate to test if the span views onto non-zero elements.
 
ARENE_NODISCARD constexpr auto end () const noexcept -> iterator
 Obtain an iterator to the one-past-the-end of the data viewed by the span.
 
template<std::size_t Count, std::size_t UE = Extent, constraints< std::enable_if_t< span_detail::is_dynamic_extent(UE)> > = nullptr>
ARENE_NODISCARD constexpr auto first () const noexcept -> span< T, Count >
 Create a new fixed-size span from the beginning of the span.
 
template<std::size_t Count, std::size_t UE = Extent>
ARENE_NODISCARD constexpr auto first () const noexcept -> span< T, Count >
 Create a new fixed-size span from the beginning of the span.
 
ARENE_NODISCARD constexpr auto first (std::size_t count) const noexcept -> span< T >
 Create a new dynamic-size span from the beginning of the span.
 
ARENE_NODISCARD constexpr auto front () const noexcept -> T &
 Access the first element in the span.
 
template<std::size_t Count, std::size_t UE = Extent, constraints< std::enable_if_t< span_detail::is_dynamic_extent(UE)> > = nullptr>
ARENE_NODISCARD constexpr auto last () const noexcept -> span< T, Count >
 Create a new fixed-size span for the last Count elements.
 
template<std::size_t Count, std::size_t UE = Extent>
ARENE_NODISCARD constexpr auto last () const noexcept -> span< T, Count >
 Create a new fixed-size span for the last Count elements.
 
ARENE_NODISCARD constexpr auto last (std::size_t count) const noexcept -> span< T >
 Create a new dynamic-size span for the last count elements.
 
constexpr auto operator= (span &&other) -> span &=default
 default move assignment operator
 
constexpr auto operator= (span const &other) -> span &=default
 default copy assignment operator
 
constexpr auto operator[] (std::size_t index) const noexcept -> T &
 Retrieve the element at the specified index into the span. index must be less than size()
 
ARENE_NODISCARD constexpr auto rbegin () const noexcept -> reverse_iterator
 Obtain an iterator to the beginning of a reversed view of the data in the span.
 
ARENE_NODISCARD constexpr auto rend () const noexcept -> reverse_iterator
 Obtain an iterator to one-past-the-end of a reversed view of the data in the span.
 
ARENE_NODISCARD constexpr auto size_bytes () const noexcept -> std::size_t
 Returns the total size in bytes of the elements in the span.
 
ARENE_NODISCARD constexpr auto ssize () const noexcept -> difference_type
 The size of the span as a signed integer.
 
template<std::size_t Offset, std::size_t Count = span_detail::get_dynamic_extent()>
ARENE_NODISCARD constexpr auto subspan () const noexcept -> span< T, span_detail::extent_for_subspan< Extent, Offset, Count >()>
 Creates a new fixed-size span which is a slice of this span.
 
template<std::size_t Offset, std::size_t Count = span_detail::get_dynamic_extent()>
ARENE_NODISCARD constexpr auto subspan () const noexcept -> span< T, span_detail::extent_for_subspan< Extent, Offset, Count >()>
 Creates a new fixed-size span which is a slice of this span.
 
template<std::size_t Offset, std::size_t Count = span_detail::get_dynamic_extent()>
ARENE_NODISCARD constexpr auto subspan () const noexcept -> span< T, span_detail::extent_for_subspan< Extent, Offset, Count >()>
 Creates a new dynamic-sized span which is a slice of this span.
 
template<std::size_t Offset, std::size_t Count = span_detail::get_dynamic_extent()>
ARENE_NODISCARD constexpr auto subspan () const noexcept -> span< T, span_detail::extent_for_subspan< Extent, Offset, Count >()>
 Creates a new fixed-size span which is a slice of this span.
 
ARENE_NODISCARD constexpr auto subspan (std::size_t offset, std::size_t count=dynamic_extent) const noexcept -> span< T >
 Creates a new dynamic-size span which is a slice of this span.
 

Static Public Attributes

static constexpr std::integral_constant< std::size_t, Extent > extent {}
 The Extent of the span — either dynamic_extent, or the fixed size.
 

Detailed Description

template<typename T, std::size_t Extent>
class arene::base::span< T, Extent >

A backport of std::span for C++14. Provides a view over a contiguous range of elements of type T.

Template Parameters
TThe type of the element the span views
ExtentThe size of the span. If set to arene::base::dynamic_extent , then the Size of the range is determined at runtime. Otherwise the range of elements is exactly Extent elements.

Member Typedef Documentation

◆ const_iterator

template<typename T, std::size_t Extent>
using arene::base::span< T, Extent >::const_iterator = detail::wrapped_iterator<const_pointer, span_detail::span_iter_passkey>

The type of an iterator into a const view of the data viewed by the span.

◆ const_pointer

template<typename T, std::size_t Extent>
using arene::base::span< T, Extent >::const_pointer = T const*

The type of pointers to const elements of the span.

◆ const_reference

template<typename T, std::size_t Extent>
using arene::base::span< T, Extent >::const_reference = T const&

The type of references to const elements of the span.

◆ const_reverse_iterator

template<typename T, std::size_t Extent>
using arene::base::span< T, Extent >::const_reverse_iterator = ::arene::base::reverse_iterator<const_iterator>

The type of an iterator into a const and reversed view of the data viewed by the span.

◆ difference_type

template<typename T, std::size_t Extent>
using arene::base::span< T, Extent >::difference_type = typename iterator::difference_type

The type used for obtaining differences between iterators of the span.

◆ element_type

template<typename T, std::size_t Extent>
using arene::base::span< T, Extent >::element_type = T

The type of the elements of the span.

◆ iterator

template<typename T, std::size_t Extent>
using arene::base::span< T, Extent >::iterator = detail::wrapped_iterator<pointer, span_detail::span_iter_passkey>

The type of an iterator into the data viewed by the span.

◆ pointer

template<typename T, std::size_t Extent>
using arene::base::span< T, Extent >::pointer = T*

The type of pointers to elements of the span.

◆ reference

template<typename T, std::size_t Extent>
using arene::base::span< T, Extent >::reference = T&

The type of references to elements of the span.

◆ reverse_iterator

template<typename T, std::size_t Extent>
using arene::base::span< T, Extent >::reverse_iterator = ::arene::base::reverse_iterator<iterator>

The type of an iterator into a reversed view of the data viewed by the span.

◆ size_type

template<typename T, std::size_t Extent>
using arene::base::span< T, Extent >::size_type = std::size_t

The type of the size of the span.

◆ value_type

template<typename T, std::size_t Extent>
using arene::base::span< T, Extent >::value_type = arene::base::remove_cvref_t<T>

The type of the elements of the span without const or volatile qualification.

Constructor & Destructor Documentation

◆ span() [1/14]

template<typename T, std::size_t Extent>
arene::base::span< T, Extent >::span ( )
constexprdefaultnoexcept

Default-constructs an empty span. Only exists if Extent==dynamic_extent or Extent==0.

Postcondition
size()==0 .

◆ span() [2/14]

template<typename T, std::size_t Extent>
arene::base::span< T, Extent >::span ( span< T, Extent > const & other)
constexprdefault

default copy constructor

Parameters
otherThe span being copied

◆ span() [3/14]

template<typename T, std::size_t Extent>
arene::base::span< T, Extent >::span ( span< T, Extent > && other)
constexprdefault

default move constructor

Parameters
otherThe span being moved

◆ ~span()

template<typename T, std::size_t Extent>
arene::base::span< T, Extent >::~span ( )
default

default destructor

◆ span() [4/14]

template<typename T, std::size_t Extent>
template<typename U, constraints< std::enable_if_t< arene::base::is_array_convertible_v< U, T > > > = nullptr>
arene::base::span< T, Extent >::span ( U * data_pointer,
std::size_t data_size )
inlineconstexprnoexcept

Construct with the specified data and size. Prevents implicit derived-to-base pointer conversions on the supplied data argument.

Template Parameters
UThe type of the data to convert from.
Parameters
data_pointerThe data from which to construct the span.
data_sizeThe size of the data span to construct.
Postcondition
size()==data_size .
data()=data_pointer .
Precondition
data_pointer+data_size must be in the valid range of data_pointer , else behavior is undefined.
data_size must satisfy is_valid_runtime_size else ARENE_PRECONDITION violation.

◆ span() [5/14]

template<typename T, std::size_t Extent>
template<std::size_t N, constraints< std::enable_if_t< is_valid_source_extent_v< N > > > = nullptr>
arene::base::span< T, Extent >::span ( T(&) array[N])
inlineconstexprnoexcept

Constructor from a c-array.

Template Parameters
NThe size of the c-array. Must satisfy is_valid_source_extent .
Parameters
arrayThe array to construct the span from
Postcondition
size()==N .
data()==&array[0] .

◆ span() [6/14]

template<typename T, std::size_t Extent>
template<template< typename U, std::size_t N > class ArrayLikeT, typename U, std::size_t N, constraints< std::enable_if_t< span_detail::has_member_data_v< ArrayLikeT< U, N > > >, std::enable_if_t< span_detail::has_tuple_size_v< ArrayLikeT< U, N > > >, std::enable_if_t< std::tuple_size< ArrayLikeT< U, N > >::value==N >, std::enable_if_t< arene::base::is_array_convertible_v< U, T > >, std::enable_if_t< is_valid_source_extent_v< N > > > = nullptr>
arene::base::span< T, Extent >::span ( ArrayLikeT< U, N > & array)
inlineconstexprnoexcept

Constructor from a std::array.

Template Parameters
ArrayLikeTThe template-template type of the array-like container. A container is array-like if it has a member function data() and std::tuple_size<ArrayLikeType<U,N>> is defined.
UThe value_type of the array. Must satisfy is_array_convertible_v<U,T>
NThe size of the array, Must satisfy is_valid_source_extent
Parameters
arrayThe array to construct the span from
Postcondition
size()==N .
data()==array.data() .

◆ span() [7/14]

template<typename T, std::size_t Extent>
template<template< typename U, std::size_t N > class ArrayLikeT, typename U, std::size_t N, constraints< std::enable_if_t< span_detail::has_member_data_v< ArrayLikeT< U, N > > >, std::enable_if_t< span_detail::has_tuple_size_v< ArrayLikeT< U, N > > >, std::enable_if_t< std::tuple_size< ArrayLikeT< U, N > >::value==N >, std::enable_if_t< std::is_const< T >::value &&arene::base::is_array_convertible_v< U, T > >, std::enable_if_t< is_valid_source_extent_v< N > > > = nullptr>
arene::base::span< T, Extent >::span ( ArrayLikeT< U, N > const & array)
inlineconstexprnoexcept

Constructor from a const std::array -like type.

Template Parameters
ArrayLikeTThe template-template type of the array-like container. A container is array-like if it has a member function data() and std::tuple_size<ArrayLikeType<U,N>> is defined.
UThe value_type of the array. Must satisfy is_array_convertible_v<const U, T>
NThe size of the array, Must satisfy is_valid_source_extent
Parameters
arrayThe array to construct the span from
Postcondition
size()==N .
data()==array.data() .

◆ span() [8/14]

template<typename T, std::size_t Extent>
template<template< typename U, std::size_t N > class ArrayLikeT, typename U, std::size_t N, constraints< std::enable_if_t< span_detail::has_member_data_v< ArrayLikeT< U, N > > >, std::enable_if_t< span_detail::has_tuple_size_v< ArrayLikeT< U, N > > >, std::enable_if_t< std::tuple_size< ArrayLikeT< U, N > >::value==N >, std::enable_if_t< arene::base::is_array_convertible_v< U, T > >, std::enable_if_t< is_valid_source_extent_v< N > > > = nullptr>
arene::base::span< T, Extent >::span ( ArrayLikeT< U, N > && array)
inlineconstexprnoexcept

Constructor from an rvalue std::array -like type.

Template Parameters
ArrayLikeTThe template-template type of the array-like container. A container is array-like if it has a member function data() and std::tuple_size<ArrayLikeType<U,N>> is defined.
UThe value_type of the array. Must satisfy is_array_convertible_v<const U, T>
NThe size of the array, Must satisfy is_valid_source_extent
Parameters
arrayThe array to construct the span from
Postcondition
size()==N .
data()==array.data() .

◆ span() [9/14]

template<typename T, std::size_t Extent>
template<template< typename U, std::size_t N > class ArrayLikeT, typename U, std::size_t N, constraints< std::enable_if_t< span_detail::has_member_data_v< ArrayLikeT< U, N > > >, std::enable_if_t< span_detail::has_tuple_size_v< ArrayLikeT< U, N > > >, std::enable_if_t< std::tuple_size< ArrayLikeT< U, N > >::value==N >, std::enable_if_t< std::is_const< T >::value &&arene::base::is_array_convertible_v< U, T > >, std::enable_if_t< is_valid_source_extent_v< N > > > = nullptr>
arene::base::span< T, Extent >::span ( ArrayLikeT< U, N > const && array)
inlineconstexprnoexcept

Constructor from an const rvalue std::array -like type.

Template Parameters
ArrayLikeTThe template-template type of the array-like container. A container is array-like if it has a member function data() and std::tuple_size<ArrayLikeType<U,N>> is defined.
UThe value_type of the array. Must satisfy is_array_convertible_v<const U, T>
NThe size of the array, Must satisfy is_valid_source_extent
Parameters
arrayThe array to construct the span from
Postcondition
size()==N .
data()==array.data() .

◆ span() [10/14]

template<typename T, std::size_t Extent>
template<typename U, std::size_t OtherExtent, constraints< std::enable_if_t< !span_detail::is_dynamic_extent(Extent) &&!span_detail::is_dynamic_extent(OtherExtent) &&Extent !=OtherExtent > > = nullptr>
arene::base::span< T, Extent >::span ( span< U, OtherExtent > && other)
constexprdeletenoexcept

Disable construction of fixed size spans from other spans of mismatched size.

Parameters
otherThe source object

◆ span() [11/14]

template<typename T, std::size_t Extent>
template<typename Container, constraints< std::enable_if_t< !span_detail::has_tuple_size_v< arene::base::remove_cvref_t< Container > > &&span_detail::is_dynamic_extent(Extent)>, std::enable_if_t< arene::base::is_array_convertible_v< arene::base::remove_reference_t< >, T > > > = nullptr>
arene::base::span< T, Extent >::span ( Container && source)
inlineconstexprnoexcept

Constructor from a container of T with contiguous elements.

Template Parameters
Containerthe type of the container to construct from. A "container" is a type which has data() and size() member functions, where data() returns a pointer (or equivalent) to contiguous memory containing elements pointer-convertible to T .
Parameters
sourceThe container to construct the span from
Precondition
If Extent is not dynamic_extent , then source.size()==Extent must be true, else it is an ARENE_PRECONDITION violation.

◆ span() [12/14]

template<typename T, std::size_t Extent>
template<typename Container, constraints< std::enable_if_t< !span_detail::has_tuple_size_v< arene::base::remove_cvref_t< Container > > &&!span_detail::is_dynamic_extent(Extent)>, std::enable_if_t< arene::base::is_array_convertible_v< arene::base::remove_reference_t< >, T > > > = nullptr>
arene::base::span< T, Extent >::span ( Container && source)
inlineexplicitconstexprnoexcept

Constructor from a container of T with contiguous elements.

Template Parameters
Containerthe type of the container to construct from. A "container" is a type which has data() and size() member functions, where data() returns a pointer (or equivalent) to contiguous memory containing elements pointer-convertible to T .
Parameters
sourceThe container to construct the span from
Precondition
If Extent is not dynamic_extent , then source.size()==Extent must be true, else it is an ARENE_PRECONDITION violation.

◆ span() [13/14]

template<typename T, std::size_t Extent>
template<typename U, std::size_t OtherExtent, constraints< std::enable_if_t< arene::base::is_array_convertible_v< U, T > >, std::enable_if_t< is_valid_source_extent_v< OtherExtent > > > = nullptr>
arene::base::span< T, Extent >::span ( span< U, OtherExtent > const & other)
inlineconstexprnoexcept

Constructor from another span<U,OtherExtent> when Extent is "no more restrictive" then OtherExtent.

Template Parameters
UThe type of the element in the other span. Must be pointer-convertible to T
OtherExtenIf Extent is not dynamic_extent , then must be equal to Extent .
Parameters
otherThe span to construct from.

◆ span() [14/14]

template<typename T, std::size_t Extent>
template<typename U, std::size_t OtherExtent, constraints< std::enable_if_t< arene::base::is_array_convertible_v< U, T > >, std::enable_if_t<(!span_detail::is_dynamic_extent(Extent)) &&span_detail::is_dynamic_extent(OtherExtent)> > = nullptr>
arene::base::span< T, Extent >::span ( span< U, OtherExtent > const & other)
inlineexplicitconstexprnoexcept

Constructor from span<U,dynamic_extent> when Extent is not dynamic_extent .

Template Parameters
UThe type of the element in the other span. Must be pointer-convertible to T
Parameters
otherThe span to construct from.
Precondition
span.size()==Extent , else ARENE_PRECONDITION violation.

Member Function Documentation

◆ back()

template<typename T, std::size_t Extent>
ARENE_NODISCARD constexpr auto arene::base::span< T, Extent >::back ( ) const -> T&
inlineconstexprnoexcept

Access the last element in the span.

Precondition
empty() must be false, else ARENE_PRECONDITION violation.
Returns
A reference to the last element in the span.

◆ begin()

template<typename T, std::size_t Extent>
ARENE_NODISCARD constexpr auto arene::base::span< T, Extent >::begin ( ) const -> iterator
inlineconstexprnoexcept

Obtain an iterator to the beginning of the data viewed by the span.

Returns
iterator An iterator pointing to the first position in the span.

◆ cbegin()

template<typename T, std::size_t Extent>
ARENE_NODISCARD constexpr auto arene::base::span< T, Extent >::cbegin ( ) const -> const_iterator
inlineconstexprnoexcept

Obtain a const_iterator to the beginning of the data viewed by the span.

Returns
const_iterator A const iterator pointing to the first position in the span.

◆ cend()

template<typename T, std::size_t Extent>
ARENE_NODISCARD constexpr auto arene::base::span< T, Extent >::cend ( ) const -> const_iterator
inlineconstexprnoexcept

Obtain a const_iterator to the one-past-the-end of the data viewed by the span.

Returns
const_iterator A const iterator equivalent to cbegin()+size() .

◆ crbegin()

template<typename T, std::size_t Extent>
ARENE_NODISCARD constexpr auto arene::base::span< T, Extent >::crbegin ( ) const -> const_reverse_iterator
inlineconstexprnoexcept

Obtain a const_iterator to the beginning of a reversed view of the data in the span.

Returns
const_reverse_iterator An iterator equivalent to const_reverse_iterator(cend())

◆ crend()

template<typename T, std::size_t Extent>
ARENE_NODISCARD constexpr auto arene::base::span< T, Extent >::crend ( ) const -> const_reverse_iterator
inlineconstexprnoexcept

Obtain a const iterator to one-past-the-end of a reversed view of the data in the span.

Returns
const_reverse_iterator A const iterator equivalent to const_reverse_iterator(cbegin())

◆ data()

template<typename T, std::size_t Extent>
ARENE_NODISCARD constexpr auto arene::base::span< T, Extent >::data ( ) const -> T*
inlineconstexprnoexcept

Accessor to the underlying data as a raw pointer.

Returns
A pointer to the start of the elements covered by the span.

◆ empty()

template<typename T, std::size_t Extent>
ARENE_NODISCARD constexpr auto arene::base::span< T, Extent >::empty ( ) const -> bool
inlineconstexprnoexcept

Predicate to test if the span views onto non-zero elements.

Returns
true if size() == 0.
false otherwise.

◆ end()

template<typename T, std::size_t Extent>
ARENE_NODISCARD constexpr auto arene::base::span< T, Extent >::end ( ) const -> iterator
inlineconstexprnoexcept

Obtain an iterator to the one-past-the-end of the data viewed by the span.

Returns
iterator An iterator equivalent to begin()+size() .

◆ first() [1/3]

template<typename T, std::size_t Extent>
template<std::size_t Count, std::size_t UE = Extent, constraints< std::enable_if_t< span_detail::is_dynamic_extent(UE)> > = nullptr>
ARENE_NODISCARD constexpr auto arene::base::span< T, Extent >::first ( ) const -> span<T, Count>
inlineconstexprnoexcept

Create a new fixed-size span from the beginning of the span.

Template Parameters
CountThe number of elements to include.
UEdummy parameter for SFINAE.
Precondition
Count<=size() . else ARENE_PRECONDITION violation.
Returns
span<T, Count> containing the first Count elements from the span.

◆ first() [2/3]

template<typename T, std::size_t Extent>
template<std::size_t Count, std::size_t UE = Extent>
ARENE_NODISCARD constexpr auto arene::base::span< T, Extent >::first ( ) const -> span<T, Count>
inlineconstexprnoexcept

Create a new fixed-size span from the beginning of the span.

Template Parameters
CountThe number of elements to include. Must be <=Extent .
Returns
span<T, Count> containing the first Count elements from the span.

◆ first() [3/3]

template<typename T, std::size_t Extent>
ARENE_NODISCARD constexpr auto arene::base::span< T, Extent >::first ( std::size_t count) const -> span<T>
inlineconstexprnoexcept

Create a new dynamic-size span from the beginning of the span.

Parameters
countThe number of elements to include.
Precondition
count must be <= size() . else ARENE_PRECONDITION violation.
Returns
span<T, Count> containing the first count elements from the span.

◆ front()

template<typename T, std::size_t Extent>
ARENE_NODISCARD constexpr auto arene::base::span< T, Extent >::front ( ) const -> T&
inlineconstexprnoexcept

Access the first element in the span.

Precondition
empty() must be false, else ARENE_PRECONDITION violation.
Returns
A reference to the first element in the span.

◆ last() [1/3]

template<typename T, std::size_t Extent>
template<std::size_t Count, std::size_t UE = Extent, constraints< std::enable_if_t< span_detail::is_dynamic_extent(UE)> > = nullptr>
ARENE_NODISCARD constexpr auto arene::base::span< T, Extent >::last ( ) const -> span<T, Count>
inlineconstexprnoexcept

Create a new fixed-size span for the last Count elements.

Template Parameters
CountThe number of elements to include.
Precondition
Count<=size() , else ARENE_PRECONDITION violation.
Returns
span<T, Count> containing the last Count elements from the span.

◆ last() [2/3]

template<typename T, std::size_t Extent>
template<std::size_t Count, std::size_t UE = Extent>
ARENE_NODISCARD constexpr auto arene::base::span< T, Extent >::last ( ) const -> span<T, Count>
inlineconstexprnoexcept

Create a new fixed-size span for the last Count elements.

Template Parameters
CountThe number of elements to include. Must be <=Extent .
Returns
span<T, Count> containing the last Count elements from the span.

◆ last() [3/3]

template<typename T, std::size_t Extent>
ARENE_NODISCARD constexpr auto arene::base::span< T, Extent >::last ( std::size_t count) const -> span<T>
inlineconstexprnoexcept

Create a new dynamic-size span for the last count elements.

Parameters
countThe number of elements to include.
Precondition
count must be <= size() . else ARENE_PRECONDITION violation.
Returns
span<T, Count> containing the last count elements from the span.

◆ operator=() [1/2]

template<typename T, std::size_t Extent>
auto arene::base::span< T, Extent >::operator= ( span< T, Extent > && other) -> span &=default
constexprdefault

default move assignment operator

Parameters
otherThe span being moved

◆ operator=() [2/2]

template<typename T, std::size_t Extent>
auto arene::base::span< T, Extent >::operator= ( span< T, Extent > const & other) -> span &=default
constexprdefault

default copy assignment operator

Parameters
otherThe span being copied

◆ operator[]()

template<typename T, std::size_t Extent>
auto arene::base::span< T, Extent >::operator[] ( std::size_t index) const -> T&
inlineconstexprnoexcept

Retrieve the element at the specified index into the span. index must be less than size()

Parameters
indexThe index of the element to access
Precondition
index < size() else ARENE_PRECONDITION violation.
Returns
A reference to the element at the specified index into the span.

◆ rbegin()

template<typename T, std::size_t Extent>
ARENE_NODISCARD constexpr auto arene::base::span< T, Extent >::rbegin ( ) const -> reverse_iterator
inlineconstexprnoexcept

Obtain an iterator to the beginning of a reversed view of the data in the span.

Returns
iterator An iterator equivalent to reverse_iterator(end())

◆ rend()

template<typename T, std::size_t Extent>
ARENE_NODISCARD constexpr auto arene::base::span< T, Extent >::rend ( ) const -> reverse_iterator
inlineconstexprnoexcept

Obtain an iterator to one-past-the-end of a reversed view of the data in the span.

Returns
iterator An iterator equivalent to reverse_iterator(begin())

◆ size_bytes()

template<typename T, std::size_t Extent>
ARENE_NODISCARD constexpr auto arene::base::span< T, Extent >::size_bytes ( ) const -> std::size_t
inlineconstexprnoexcept

Returns the total size in bytes of the elements in the span.

Returns
The total size, in bytes, of the elements in the span.

◆ ssize()

template<typename T, std::size_t Extent>
ARENE_NODISCARD constexpr auto arene::base::span< T, Extent >::ssize ( ) const -> difference_type
inlineconstexprnoexcept

The size of the span as a signed integer.

Returns
The size

◆ subspan() [1/5]

template<typename T, std::size_t Extent>
template<std::size_t Offset, std::size_t Count = span_detail::get_dynamic_extent()>
ARENE_NODISCARD constexpr auto arene::base::span< T, Extent >::subspan ( ) const -> span<T, span_detail::extent_for_subspan<Extent, Offset, Count>()>
inlineconstexprnoexcept

Creates a new fixed-size span which is a slice of this span.

Template Parameters
OffsetThe index of the first element to contain in the subspan. Must be <=Extent
CountThe number of elements to include in the subspan. Must satisfy Offset+Count<=Extent , or be dynamic_extent .
Returns
span<T,Extent-Offset> Equivalent to last<Extent-Offset>() .

◆ subspan() [2/5]

template<typename T, std::size_t Extent>
template<std::size_t Offset, std::size_t Count = span_detail::get_dynamic_extent()>
ARENE_NODISCARD constexpr auto arene::base::span< T, Extent >::subspan ( ) const -> span<T, span_detail::extent_for_subspan<Extent, Offset, Count>()>
inlineconstexprnoexcept

Creates a new fixed-size span which is a slice of this span.

Template Parameters
OffsetThe index of the first element to contain in the subspan. Must be <=Extent
CountThe number of elements to include in the subspan. Must satisfy Offset+Count<=Extent , or be dynamic_extent .
Returns
span<T,Count> Equivalent to last<Extent-Offset>().first<Count>() .

◆ subspan() [3/5]

template<typename T, std::size_t Extent>
template<std::size_t Offset, std::size_t Count = span_detail::get_dynamic_extent()>
ARENE_NODISCARD constexpr auto arene::base::span< T, Extent >::subspan ( ) const -> span<T, span_detail::extent_for_subspan<Extent, Offset, Count>()>
inlineconstexprnoexcept

Creates a new dynamic-sized span which is a slice of this span.

Template Parameters
OffsetThe index of the first element to contain in the subspan. Must be <= size()
CountThe number of elements to include in the subspan. offset + count must be <= size()
Returns
span<T> equivalent to last(size()-Offset) .
Precondition
Count<= size() && (Count+Offset <= size()) , else ARENE_PRECONDITION violation.

◆ subspan() [4/5]

template<typename T, std::size_t Extent>
template<std::size_t Offset, std::size_t Count = span_detail::get_dynamic_extent()>
ARENE_NODISCARD constexpr auto arene::base::span< T, Extent >::subspan ( ) const -> span<T, span_detail::extent_for_subspan<Extent, Offset, Count>()>
inlineconstexprnoexcept

Creates a new fixed-size span which is a slice of this span.

Template Parameters
OffsetThe index of the first element to contain in the subspan. Must be <= size()
CountThe number of elements to include in the subspan. offset + count must be <= size()
Returns
span<T,Count> Equivalent to last(size()-Offset).first<Count>() .
Precondition
If Extent is dynamic_extent , then Count<= size() && (Count+Offset <= size()) , else ARENE_PRECONDITION violation.

◆ subspan() [5/5]

template<typename T, std::size_t Extent>
ARENE_NODISCARD constexpr auto arene::base::span< T, Extent >::subspan ( std::size_t offset,
std::size_t count = dynamic_extent ) const -> span<T>
inlineconstexprnoexcept

Creates a new dynamic-size span which is a slice of this span.

Parameters
offsetThe index of the first element to contain in the subspan. Must be <= size()
countThe number of elements to include in the subspan. offset + count must be <= size()
Returns
span<T> If count==dynamic_extent , equivalent to last(size()-offset) , else last(size()-offset).first(count) .
Precondition
count<= size() && (count+offset <= size()) , else ARENE_PRECONDITION violation.

Member Data Documentation

◆ extent

template<typename T, std::size_t Extent>
std::integral_constant<std::size_t, Extent> arene::base::span< T, Extent >::extent {}
staticconstexpr

The Extent of the span — either dynamic_extent, or the fixed size.


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