vitrio 0.1.4
High-throughput image I/O for Cryo-Electron Microscopy (CryoEM)
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
vitrio::span< T > Class Template Reference

A view of a contiguous sequence of elements. More...

#include <vitrio/span.hpp>

Public Types

using element_type = T
 
using value_type = typename std::remove_cv< T >::type
 
using size_type = std::size_t
 
using difference_type = std::ptrdiff_t
 
using pointer = T *
 
using reference = T &
 
using iterator = T *
 

Public Member Functions

constexpr span () noexcept
 Construct a span of no elements.
 
constexpr span (pointer data, size_type size) noexcept
 Construct a span from its first element and its size.
 
template<typename U , typename = typename std::enable_if< std::is_convertible<U (*)[], T (*)[]>::value >::type>
constexpr span (const span< U > &other) noexcept
 Construct a span from one of a less qualified element type.
 
 span (const span &other)=default
 
span & operator= (const span &other)=default
 
constexpr pointer data () const noexcept
 Get the first element.
 
constexpr size_type size () const noexcept
 Get the number of elements.
 
constexpr bool empty () const noexcept
 Check whether the span has no elements.
 
constexpr reference operator[] (size_type index) const noexcept
 Get one element.
 
constexpr reference front () const noexcept
 Get the first element.
 
constexpr reference back () const noexcept
 Get the last element.
 
constexpr iterator begin () const noexcept
 Get an iterator to the first element.
 
constexpr iterator end () const noexcept
 Get an iterator past the last element.
 

Detailed Description

template<typename T>
class vitrio::span< T >

A view of a contiguous sequence of elements.

A span refers to elements it does not own, through a pointer to the first one and a count. Copying a span copies the reference and not the elements. The elements must outlive every span that refers to them.

A span of a const type gives read-only access to its elements. A span of a non-const type converts to it.

Template Parameters
TType of the elements. It may be const.

Constructor & Destructor Documentation

◆ span() [1/2]

template<typename T >
constexpr vitrio::span< T >::span ( pointer  data,
size_type  size 
)
constexprnoexcept

Construct a span from its first element and its size.

Parameters
dataPointer to the first element.
sizeNumber of elements.

◆ span() [2/2]

template<typename T >
template<typename U , typename = typename std::enable_if< std::is_convertible<U (*)[], T (*)[]>::value >::type>
constexpr vitrio::span< T >::span ( const span< U > &  other)
constexprnoexcept

Construct a span from one of a less qualified element type.

This is what converts a span of non-const elements into one of const elements.

Template Parameters
UElement type of the other span.
Parameters
otherThe span to refer to the elements of.

Member Function Documentation

◆ back()

template<typename T >
constexpr reference vitrio::span< T >::back ( ) const
constexprnoexcept

Get the last element.

The span must not be empty.

Returns
reference The last element.

◆ begin()

template<typename T >
constexpr iterator vitrio::span< T >::begin ( ) const
constexprnoexcept

Get an iterator to the first element.

Returns
iterator The iterator.

◆ data()

template<typename T >
constexpr pointer vitrio::span< T >::data ( ) const
constexprnoexcept

Get the first element.

Returns
pointer Pointer to the first element.

◆ empty()

template<typename T >
constexpr bool vitrio::span< T >::empty ( ) const
constexprnoexcept

Check whether the span has no elements.

Returns
true The span has no elements.
false The span has at least one element.

◆ end()

template<typename T >
constexpr iterator vitrio::span< T >::end ( ) const
constexprnoexcept

Get an iterator past the last element.

Returns
iterator The iterator.

◆ front()

template<typename T >
constexpr reference vitrio::span< T >::front ( ) const
constexprnoexcept

Get the first element.

The span must not be empty.

Returns
reference The first element.

◆ operator[]()

template<typename T >
constexpr reference vitrio::span< T >::operator[] ( size_type  index) const
constexprnoexcept

Get one element.

Parameters
indexPosition of the element. Must be below size.
Returns
reference The element.

◆ size()

template<typename T >
constexpr size_type vitrio::span< T >::size ( ) const
constexprnoexcept

Get the number of elements.

Returns
size_type The number of elements.

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