Bifrost SDK
Bifrost SDK documentation
Amino::Span< T > Class Template Reference

The class template span describes an object that can refer to a contiguous sequence of objects with the first element of the sequence at position zero. More...

#include <Span.h>

Inheritance diagram for Amino::Span< T >:
Amino::SpanParam< T >

Public Types

using element_type = T
 
using value_type = std::remove_cv_t< T >
 
using iterator = T *
 
using const_iterator = T const *
 
using size_type = size_t
 
using difference_type = ptrdiff_t
 

Public Member Functions

constexpr Span () noexcept=default
 Default constructor (empty Span). More...
 
constexpr Span (T *data, size_type size)
 Construct a Span from a pointer and a size. More...
 
constexpr Span (T *begin, T *end)
 Construct a Span from a pointer to the beginning and a pointer to the end. More...
 
template<typename R , typename = std::enable_if_t<!is_span<R>>>
constexpr Span (R &&r)
 
constexpr bool empty () const
 Check if the Span is empty. More...
 
constexpr T * data () const
 Direct access to the underlying contiguous storage of the Span. More...
 
constexpr size_type size () const
 Returns the number of elements in the Span. More...
 
constexpr Span (std::nullptr_t, size_type)=delete
 Span is not constructible from a nullptr. More...
 
constexpr Span (T *, std::nullptr_t)=delete
 Span is not constructible from a nullptr. More...
 
constexpr Span (std::nullptr_t, T *)=delete
 Span is not constructible from a nullptr. More...
 
constexpr T const & operator[] (size_type i) const
 Access the ith element. More...
 
constexpr T & operator[] (size_type i)
 Access the ith element. More...
 
constexpr T const & front () const
 Access the first element. More...
 
constexpr T & front ()
 Access the first element. More...
 
constexpr T const & back () const
 Access the last element. More...
 
constexpr T & back ()
 Access the last element. More...
 
constexpr const_iterator cbegin () const
 Returns an iterator to the beginning of the Span. More...
 
constexpr const_iterator begin () const
 Returns an iterator to the beginning of the Span. More...
 
constexpr iterator begin ()
 Returns an iterator to the beginning of the Span. More...
 
constexpr const_iterator cend () const
 Returns an iterator to the end of the Span. More...
 
constexpr const_iterator end () const
 Returns an iterator to the end of the Span. More...
 
constexpr iterator end ()
 Returns an iterator to the end of the Span. More...
 

Detailed Description

template<typename T>
class Amino::Span< T >

The class template span describes an object that can refer to a contiguous sequence of objects with the first element of the sequence at position zero.

Note
This is essentially a simplified version of std::span from C++20.

Definition at line 35 of file Span.h.

Member Typedef Documentation

◆ const_iterator

template<typename T >
using Amino::Span< T >::const_iterator = T const*

Definition at line 47 of file Span.h.

◆ difference_type

template<typename T >
using Amino::Span< T >::difference_type = ptrdiff_t

Definition at line 49 of file Span.h.

◆ element_type

template<typename T >
using Amino::Span< T >::element_type = T

Definition at line 44 of file Span.h.

◆ iterator

template<typename T >
using Amino::Span< T >::iterator = T*

Definition at line 46 of file Span.h.

◆ size_type

template<typename T >
using Amino::Span< T >::size_type = size_t

Definition at line 48 of file Span.h.

◆ value_type

template<typename T >
using Amino::Span< T >::value_type = std::remove_cv_t<T>

Definition at line 45 of file Span.h.

Constructor & Destructor Documentation

◆ Span() [1/7]

template<typename T >
constexpr Amino::Span< T >::Span ( )
constexprdefaultnoexcept

Default constructor (empty Span).

◆ Span() [2/7]

template<typename T >
constexpr Amino::Span< T >::Span ( T *  data,
size_type  size 
)
inlineconstexpr

Construct a Span from a pointer and a size.

Definition at line 57 of file Span.h.

References Amino::Span< T >::data().

◆ Span() [3/7]

template<typename T >
constexpr Amino::Span< T >::Span ( T *  begin,
T *  end 
)
inlineconstexpr

Construct a Span from a pointer to the beginning and a pointer to the end.

Definition at line 64 of file Span.h.

References Amino::Span< T >::begin(), and Amino::Span< T >::end().

◆ Span() [4/7]

template<typename T >
template<typename R , typename = std::enable_if_t<!is_span<R>>>
constexpr Amino::Span< T >::Span ( R &&  r)
inlineexplicitconstexpr

Definition at line 69 of file Span.h.

◆ Span() [5/7]

template<typename T >
constexpr Amino::Span< T >::Span ( std::nullptr_t  ,
size_type   
)
constexprdelete

Span is not constructible from a nullptr.

◆ Span() [6/7]

template<typename T >
constexpr Amino::Span< T >::Span ( T *  ,
std::nullptr_t   
)
constexprdelete

Span is not constructible from a nullptr.

◆ Span() [7/7]

template<typename T >
constexpr Amino::Span< T >::Span ( std::nullptr_t  ,
T *   
)
constexprdelete

Span is not constructible from a nullptr.

Member Function Documentation

◆ back() [1/2]

template<typename T >
constexpr T & Amino::Span< T >::back ( )
inlineconstexpr

Access the last element.

Precondition
The span is not empty.

Definition at line 118 of file Span.h.

References Amino::Span< T >::empty().

◆ back() [2/2]

template<typename T >
constexpr T const & Amino::Span< T >::back ( ) const
inlineconstexpr

Access the last element.

Precondition
The span is not empty.

Definition at line 114 of file Span.h.

References Amino::Span< T >::empty().

◆ begin() [1/2]

template<typename T >
constexpr iterator Amino::Span< T >::begin ( )
inlineconstexpr

Returns an iterator to the beginning of the Span.

Definition at line 128 of file Span.h.

◆ begin() [2/2]

template<typename T >
constexpr const_iterator Amino::Span< T >::begin ( ) const
inlineconstexpr

Returns an iterator to the beginning of the Span.

Definition at line 127 of file Span.h.

Referenced by Amino::Span< T >::Span().

◆ cbegin()

template<typename T >
constexpr const_iterator Amino::Span< T >::cbegin ( ) const
inlineconstexpr

Returns an iterator to the beginning of the Span.

Definition at line 126 of file Span.h.

◆ cend()

template<typename T >
constexpr const_iterator Amino::Span< T >::cend ( ) const
inlineconstexpr

Returns an iterator to the end of the Span.

Definition at line 133 of file Span.h.

◆ data()

template<typename T >
constexpr T * Amino::Span< T >::data ( ) const
inlineconstexpr

Direct access to the underlying contiguous storage of the Span.

Definition at line 140 of file Span.h.

Referenced by Amino::Span< T >::Span().

◆ empty()

template<typename T >
constexpr bool Amino::Span< T >::empty ( ) const
inlineconstexpr

Check if the Span is empty.

Definition at line 80 of file Span.h.

Referenced by Amino::Span< T >::back(), and Amino::Span< T >::front().

◆ end() [1/2]

template<typename T >
constexpr iterator Amino::Span< T >::end ( )
inlineconstexpr

Returns an iterator to the end of the Span.

Definition at line 135 of file Span.h.

◆ end() [2/2]

template<typename T >
constexpr const_iterator Amino::Span< T >::end ( ) const
inlineconstexpr

Returns an iterator to the end of the Span.

Definition at line 134 of file Span.h.

Referenced by Amino::Span< T >::Span().

◆ front() [1/2]

template<typename T >
constexpr T & Amino::Span< T >::front ( )
inlineconstexpr

Access the first element.

Precondition
The span is not empty.

Definition at line 104 of file Span.h.

References Amino::Span< T >::empty().

◆ front() [2/2]

template<typename T >
constexpr T const & Amino::Span< T >::front ( ) const
inlineconstexpr

Access the first element.

Precondition
The span is not empty.

Definition at line 100 of file Span.h.

References Amino::Span< T >::empty().

◆ operator[]() [1/2]

template<typename T >
constexpr T & Amino::Span< T >::operator[] ( size_type  i)
inlineconstexpr

Access the ith element.

Precondition
i < size()

Definition at line 90 of file Span.h.

References Amino::Span< T >::size().

◆ operator[]() [2/2]

template<typename T >
constexpr T const & Amino::Span< T >::operator[] ( size_type  i) const
inlineconstexpr

Access the ith element.

Precondition
i < size()

Definition at line 86 of file Span.h.

References Amino::Span< T >::size().

◆ size()

template<typename T >
constexpr size_type Amino::Span< T >::size ( ) const
inlineconstexpr

Returns the number of elements in the Span.

Definition at line 143 of file Span.h.

Referenced by Amino::Span< T >::operator[]().