tdslite latest
C++ API reference
Loading...
Searching...
No Matches
tdsl::span< T > Struct Template Reference

Span of T. More...

#include <tdslite/util/tdsl_span.hpp>

Public Types

using element_type = T
 
using value_type = typename traits::remove_cv< T >::type
 
using size_type = tdsl::size_t
 
using ssize_type = tdsl::ssize_t
 
using pointer = T *
 
using const_pointer = const T *
 
using reference = T &
 
using const_reference = const T &
 
using iterator = pointer
 
using const_iterator = const_pointer
 
using self_type = span< element_type >
 

Public Member Functions

constexpr span () noexcept=default
 Default c-tor.
 
constexpr span (const self_type &other) noexcept
 Copy c-tor.
 
constexpr span (self_type &&other) noexcept
 Move c-tor.
 
constexpr span (element_type *elem, size_type elem_count) noexcept
 Construct a new span object.
 
constexpr span (element_type *begin, element_type *end) noexcept
 Construct a new span object from explicit begin and end parameters.
 
template<size_type N>
constexpr span (element_type(&buffer)[N]) noexcept
 Construct a new span object from a fixed-size array.
 
span & operator= (const self_type &other) noexcept
 Copy assignment.
 
span & operator= (self_type &&other) noexcept
 Move assignment.
 
constexpr bool operator== (const self_type &other) const noexcept
 Equality comparison operator.
 
constexpr auto size_bytes () const noexcept -> size_type
 Get the amount of the bytes in the span.
 
constexpr auto size () const noexcept -> size_type
 Get the amount of the elements in the span.
 
constexpr auto ssize () const noexcept -> ssize_type
 Get the amount of the elements in the span.
 
constexpr auto data () const noexcept -> pointer
 Data pointer.
 
constexpr auto begin () const noexcept -> iterator
 Iterator interface begin() function.
 
constexpr auto end () const noexcept -> iterator
 Iterator interface end() function.
 
constexpr auto cbegin () const noexcept -> const_iterator
 Iterator interface begin() function.
 
constexpr auto cend () const noexcept -> const_iterator
 Iterator interface end() function.
 
auto operator[] (size_type index) const noexcept -> reference
 Subscript operator.
 
 operator bool () const noexcept
 Make span boolable, so it can be used expressions like: span<int> span_v; ... if(span_v){ ..do stuff.
 
template<typename Q , traits::enable_when::integral< Q > = true>
constexpr auto rebind_cast () const noexcept -> span< const Q >
 Cast span to another span with new element type.
 

Protected Attributes

size_type element_count {0}
 Size of the span (in element count)
 

Detailed Description

template<typename T = const tdsl::uint8_t>
struct tdsl::span< T >

Span of T.

Member Typedef Documentation

◆ element_type

template<typename T = const tdsl::uint8_t>
using tdsl::span< T >::element_type = T

◆ value_type

template<typename T = const tdsl::uint8_t>
using tdsl::span< T >::value_type = typename traits::remove_cv<T>::type

◆ size_type

template<typename T = const tdsl::uint8_t>
using tdsl::span< T >::size_type = tdsl::size_t

◆ ssize_type

template<typename T = const tdsl::uint8_t>
using tdsl::span< T >::ssize_type = tdsl::ssize_t

◆ pointer

template<typename T = const tdsl::uint8_t>
using tdsl::span< T >::pointer = T *

◆ const_pointer

template<typename T = const tdsl::uint8_t>
using tdsl::span< T >::const_pointer = const T *

◆ reference

template<typename T = const tdsl::uint8_t>
using tdsl::span< T >::reference = T &

◆ const_reference

template<typename T = const tdsl::uint8_t>
using tdsl::span< T >::const_reference = const T &

◆ iterator

template<typename T = const tdsl::uint8_t>
using tdsl::span< T >::iterator = pointer

◆ const_iterator

template<typename T = const tdsl::uint8_t>
using tdsl::span< T >::const_iterator = const_pointer

◆ self_type

template<typename T = const tdsl::uint8_t>
using tdsl::span< T >::self_type = span<element_type>

Constructor & Destructor Documentation

◆ span() [1/6]

template<typename T = const tdsl::uint8_t>
constexpr tdsl::span< T >::span ( )
inlineconstexprdefaultnoexcept

Default c-tor.

◆ span() [2/6]

template<typename T = const tdsl::uint8_t>
constexpr tdsl::span< T >::span ( const self_type &  other)
inlineconstexprnoexcept

Copy c-tor.

◆ span() [3/6]

template<typename T = const tdsl::uint8_t>
constexpr tdsl::span< T >::span ( self_type &&  other)
inlineconstexprnoexcept

Move c-tor.

◆ span() [4/6]

template<typename T = const tdsl::uint8_t>
constexpr tdsl::span< T >::span ( element_type *  elem,
size_type  elem_count 
)
inlineexplicitconstexprnoexcept

Construct a new span object.

Parameters
[in]elemPointer to the starting element
[in]elem_countElement count

◆ span() [5/6]

template<typename T = const tdsl::uint8_t>
constexpr tdsl::span< T >::span ( element_type *  begin,
element_type *  end 
)
inlineexplicitconstexprnoexcept

Construct a new span object from explicit begin and end parameters.

Parameters
[in]beginStart of the span.
[in]endEnd of the span. Must be greater than begin
Note
end must point to one past last element
start must be always lesser than end
end must be always greater than start

◆ span() [6/6]

template<typename T = const tdsl::uint8_t>
template<size_type N>
constexpr tdsl::span< T >::span ( element_type(&)  buffer[N])
inlineconstexprnoexcept

Construct a new span object from a fixed-size array.

Template Parameters
NAuto-deduced length of the array
Parameters
[in]bufferFixed-size buffer

Member Function Documentation

◆ operator=() [1/2]

template<typename T = const tdsl::uint8_t>
span & tdsl::span< T >::operator= ( const self_type &  other)
inlinenoexcept

Copy assignment.

◆ operator=() [2/2]

template<typename T = const tdsl::uint8_t>
span & tdsl::span< T >::operator= ( self_type &&  other)
inlinenoexcept

Move assignment.

◆ operator==()

template<typename T = const tdsl::uint8_t>
constexpr bool tdsl::span< T >::operator== ( const self_type &  other) const
inlineconstexprnoexcept

Equality comparison operator.

Two spans are considered equal if they point to same memory

Parameters
[in]otherSpan to compare against
Returns
true Spans are equal
false otherwise

◆ size_bytes()

template<typename T = const tdsl::uint8_t>
constexpr auto tdsl::span< T >::size_bytes ( ) const -> size_type
inlineconstexprnoexcept

Get the amount of the bytes in the span.

Returns
size_type Amount of the bytes in the span

◆ size()

template<typename T = const tdsl::uint8_t>
constexpr auto tdsl::span< T >::size ( ) const -> size_type
inlineconstexprnoexcept

Get the amount of the elements in the span.

Returns
size_type Amount of the element in the span

◆ ssize()

template<typename T = const tdsl::uint8_t>
constexpr auto tdsl::span< T >::ssize ( ) const -> ssize_type
inlineconstexprnoexcept

Get the amount of the elements in the span.

Returns
size_type Amount of the element in the span

◆ data()

template<typename T = const tdsl::uint8_t>
constexpr auto tdsl::span< T >::data ( ) const -> pointer
inlineconstexprnoexcept

Data pointer.

Returns
T* Pointer to the beginning of the span

◆ begin()

template<typename T = const tdsl::uint8_t>
constexpr auto tdsl::span< T >::begin ( ) const -> iterator
inlineconstexprnoexcept

Iterator interface begin() function.

Returns
T* Pointer to the beginning of the span

◆ end()

template<typename T = const tdsl::uint8_t>
constexpr auto tdsl::span< T >::end ( ) const -> iterator
inlineconstexprnoexcept

Iterator interface end() function.

Returns
T* Pointer to the one past last element of the span

◆ cbegin()

template<typename T = const tdsl::uint8_t>
constexpr auto tdsl::span< T >::cbegin ( ) const -> const_iterator
inlineconstexprnoexcept

Iterator interface begin() function.

Returns
T* Pointer to the beginning of the span

◆ cend()

template<typename T = const tdsl::uint8_t>
constexpr auto tdsl::span< T >::cend ( ) const -> const_iterator
inlineconstexprnoexcept

Iterator interface end() function.

Returns
T* Pointer to the one past last element of the span

◆ operator[]()

template<typename T = const tdsl::uint8_t>
auto tdsl::span< T >::operator[] ( size_type  index) const -> reference
inlinenoexcept

Subscript operator.

Parameters
[in]indexElement to access
Returns
reference Reference to the element

◆ operator bool()

template<typename T = const tdsl::uint8_t>
tdsl::span< T >::operator bool ( ) const
inlinenoexcept

Make span boolable, so it can be used expressions like: span<int> span_v; ... if(span_v){ ..do stuff.

}

Returns
true if data is not nullptr and size is greater than zero
false otherwise

◆ rebind_cast()

template<typename T = const tdsl::uint8_t>
template<typename Q , traits::enable_when::integral< Q > = true>
constexpr auto tdsl::span< T >::rebind_cast ( ) const -> span<const Q>
inlineconstexprnoexcept

Cast span to another span with new element type.

Template Parameters
QNew element type
Returns
span<const Q> New span
Note
If the original span's size_bytes() is not a multiple of sizeof(Q), the element count of the resulting span will be rounded down.

Member Data Documentation

◆ element_count

template<typename T = const tdsl::uint8_t>
size_type tdsl::span< T >::element_count {0}
protected

Size of the span (in element count)


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