playrho::Span< T > Class Template Reference

A C++ encapsulation of an array and its size. More...

#include <Span.hpp>

Public Types

using data_type = T
 Data type. More...
 
using pointer = data_type *
 Pointer type. More...
 
using const_pointer = const data_type *
 Constant pointer type. More...
 
using size_type = std::size_t
 Size type. More...
 

Public Member Functions

 Span ()=default
 
 Span (const Span &copy)=default
 Copy constructor. More...
 
PLAYRHO_CONSTEXPR Span (pointer array, size_type size) noexcept
 Initializing constructor. More...
 
template<std::size_t SIZE>
PLAYRHO_CONSTEXPR Span (data_type(&array)[SIZE]) noexcept
 Initializing constructor. More...
 
template<typename U , typename = std::enable_if_t< !std::is_array<U>::value >>
PLAYRHO_CONSTEXPR Span (U &value) noexcept
 Initializing constructor. More...
 
PLAYRHO_CONSTEXPR Span (std::initializer_list< T > list) noexcept
 Initializing constructor. More...
 
pointer begin () const noexcept
 Gets the "begin" iterator value. More...
 
const_pointer cbegin () const noexcept
 Gets the "begin" iterator value. More...
 
pointer end () const noexcept
 Gets the "end" iterator value. More...
 
const_pointer cend () const noexcept
 Gets the "end" iterator value. More...
 
data_typeoperator[] (size_type index) noexcept
 Accesses the indexed element. More...
 
const data_typeoperator[] (size_type index) const noexcept
 Accesses the indexed element. More...
 
PLAYRHO_CONSTEXPR size_type size () const noexcept
 Gets the size of this span. More...
 
pointer data () const noexcept
 Direct access to data. More...
 
PLAYRHO_CONSTEXPR bool empty () const noexcept
 Checks whether this span is empty. More...
 

Detailed Description

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

A C++ encapsulation of an array and its size.

Note
This is conceptually like the Guideline Support Library's span template class.
See also
http://open-std.org/JTC1/SC22/WG21/docs/papers/2016/p0122r1.pdf

Definition at line 39 of file Span.hpp.

Member Typedef Documentation

◆ data_type

template<typename T >
using playrho::Span< T >::data_type = T

Data type.

Definition at line 44 of file Span.hpp.

◆ pointer

template<typename T >
using playrho::Span< T >::pointer = data_type*

Pointer type.

Definition at line 47 of file Span.hpp.

◆ const_pointer

template<typename T >
using playrho::Span< T >::const_pointer = const data_type *

Constant pointer type.

Definition at line 50 of file Span.hpp.

◆ size_type

template<typename T >
using playrho::Span< T >::size_type = std::size_t

Size type.

Definition at line 53 of file Span.hpp.

Constructor & Destructor Documentation

◆ Span() [1/6]

template<typename T >
playrho::Span< T >::Span ( )
default

◆ Span() [2/6]

template<typename T >
playrho::Span< T >::Span ( const Span< T > &  copy)
default

Copy constructor.

◆ Span() [3/6]

template<typename T >
PLAYRHO_CONSTEXPR playrho::Span< T >::Span ( pointer  array,
size_type  size 
)
inlinenoexcept

Initializing constructor.

Definition at line 61 of file Span.hpp.

◆ Span() [4/6]

template<typename T >
template<std::size_t SIZE>
PLAYRHO_CONSTEXPR playrho::Span< T >::Span ( data_type(&)  array[SIZE])
inlinenoexcept

Initializing constructor.

Definition at line 68 of file Span.hpp.

◆ Span() [5/6]

template<typename T >
template<typename U , typename = std::enable_if_t< !std::is_array<U>::value >>
PLAYRHO_CONSTEXPR playrho::Span< T >::Span ( U &  value)
inlinenoexcept

Initializing constructor.

Definition at line 72 of file Span.hpp.

◆ Span() [6/6]

template<typename T >
PLAYRHO_CONSTEXPR playrho::Span< T >::Span ( std::initializer_list< T >  list)
inlinenoexcept

Initializing constructor.

Definition at line 76 of file Span.hpp.

Member Function Documentation

◆ begin()

template<typename T >
pointer playrho::Span< T >::begin ( ) const
inlinenoexcept

Gets the "begin" iterator value.

Definition at line 80 of file Span.hpp.

◆ cbegin()

template<typename T >
const_pointer playrho::Span< T >::cbegin ( ) const
inlinenoexcept

Gets the "begin" iterator value.

Definition at line 83 of file Span.hpp.

◆ end()

template<typename T >
pointer playrho::Span< T >::end ( ) const
inlinenoexcept

Gets the "end" iterator value.

Definition at line 86 of file Span.hpp.

◆ cend()

template<typename T >
const_pointer playrho::Span< T >::cend ( ) const
inlinenoexcept

Gets the "end" iterator value.

Definition at line 89 of file Span.hpp.

◆ operator[]() [1/2]

template<typename T >
data_type& playrho::Span< T >::operator[] ( size_type  index)
inlinenoexcept

Accesses the indexed element.

Definition at line 92 of file Span.hpp.

◆ operator[]() [2/2]

template<typename T >
const data_type& playrho::Span< T >::operator[] ( size_type  index) const
inlinenoexcept

Accesses the indexed element.

Definition at line 99 of file Span.hpp.

◆ size()

template<typename T >
PLAYRHO_CONSTEXPR size_type playrho::Span< T >::size ( ) const
inlinenoexcept

Gets the size of this span.

Definition at line 106 of file Span.hpp.

◆ data()

template<typename T >
pointer playrho::Span< T >::data ( ) const
inlinenoexcept

Direct access to data.

Definition at line 109 of file Span.hpp.

◆ empty()

template<typename T >
PLAYRHO_CONSTEXPR bool playrho::Span< T >::empty ( ) const
inlinenoexcept

Checks whether this span is empty.

Definition at line 112 of file Span.hpp.


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