Celeritas 0.6.0-dev.115+3b60a5fd
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
celeritas::Span< T, Extent > Class Template Reference

Non-owning reference to a contiguous span of data. More...

#include <Span.hh>

Public Types

Type aliases
using element_type = typename SpanTraitsT::element_type
 
using value_type = std::remove_cv_t< element_type >
 
using size_type = std::size_t
 
using pointer = typename SpanTraitsT::pointer
 
using const_pointer = typename SpanTraitsT::const_pointer
 
using reference = typename SpanTraitsT::reference
 
using const_reference = typename SpanTraitsT::const_reference
 
using iterator = typename SpanTraitsT::iterator
 
using const_iterator = typename SpanTraitsT::const_iterator
 

Public Member Functions

constexpr Span ()=default
 Construct with default null pointer and size zero.
 
CELER_CONSTEXPR_FUNCTION Span (pointer d, size_type s)
 Construct from data and size.
 
template<class Iter >
CELER_CONSTEXPR_FUNCTION Span (Iter first, Iter last)
 Construct from two contiguous random-access iterators.
 
template<std::size_t N>
CELER_CONSTEXPR_FUNCTION Span (element_type(&arr)[N])
 Construct from a C array.
 
template<class U , std::size_t N>
CELER_CONSTEXPR_FUNCTION Span (Span< U, N > const &other)
 Construct from another span.
 
 CELER_DEFAULT_COPY_MOVE (Span)
 
Iterators
CELER_CONSTEXPR_FUNCTION iterator begin () const
 
CELER_CONSTEXPR_FUNCTION iterator end () const
 
Element access
CELER_CONSTEXPR_FUNCTION reference operator[] (size_type i) const
 
CELER_CONSTEXPR_FUNCTION reference front () const
 
CELER_CONSTEXPR_FUNCTION reference back () const
 
CELER_CONSTEXPR_FUNCTION pointer data () const
 
Observers
CELER_CONSTEXPR_FUNCTION bool empty () const
 
CELER_CONSTEXPR_FUNCTION size_type size () const
 
CELER_CONSTEXPR_FUNCTION size_type size_bytes () const
 
Subviews
template<std::size_t Count>
CELER_CONSTEXPR_FUNCTION Span< T, Countfirst () const
 
CELER_CONSTEXPR_FUNCTION Span< T, dynamic_extentfirst (std::size_t count) const
 
template<std::size_t Offset, std::size_t Count = dynamic_extent>
CELER_CONSTEXPR_FUNCTION Span< T, detail::subspan_extent(Extent, Offset, Count)> subspan () const
 
CELER_CONSTEXPR_FUNCTION Span< T, dynamic_extentsubspan (std::size_t offset, std::size_t count=dynamic_extent) const
 
template<std::size_t Count>
CELER_CONSTEXPR_FUNCTION Span< T, Countlast () const
 
CELER_CONSTEXPR_FUNCTION Span< T, dynamic_extentlast (std::size_t count) const
 

Static Public Attributes

static constexpr std::size_t extent = Extent
 Size (may be dynamic)
 

Detailed Description

template<class T, std::size_t Extent = dynamic_extent>
class celeritas::Span< T, Extent >

Non-owning reference to a contiguous span of data.

Template Parameters
Tvalue type
Extentfixed size; defaults to dynamic.

This Span class is a modified backport of the C++20 std::span . In Celeritas, it is often used as a return value from accessing elements in a Collection.

Like the celeritas::Array , this class is not 100% compatible with the std::span class. The hope is that it will be complete and correct for the use cases needed by Celeritas (and, as a bonus, it will be device-compatible).

Span can be instantiated with the special marker type LdgValue<T> to optimize constant data access in global device memory. In that case, data returned by front, back, operator[] and begin / end iterators use value semantics instead of reference. The data accessor still returns a pointer to the underlying memory and can be used to bypass using LdgIterator .


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