template <typename Soa>
soagen::span class

A span type for representing some subset of a SoA container's rows.

Public types

using const_iterator = soagen::const_iterator_type<Soa>
Row iterators returned by "c"-prefixed iterator functions.
using const_span_type = soagen::const_span_type<Soa>
Const-qualified span type.
using difference_type = std::ptrdiff_t
Signed integer difference type used by the corresponding SoA type.
using iterator = soagen::iterator_type<Soa>
Row iterators returned by iterator functions.
using row_type = soagen::row_type<Soa>
soagen::row type used by this span.
using size_type = std::size_t
Unsigned integer size type used by the corresponding SoA type.
using soa_ref = coerce_ref<Soa>
Cvref-qualified version of soa_type.
using soa_type = remove_cvref<Soa>
Base SoA type for this span.
using span_type = span
Alias for this span.

Constructors, destructors, conversion operators

span() constexpr noexcept
Default constructor.
span(const span&) defaulted
Copy constructor.
span(soa_ref soa, size_type start, size_type count = static_cast<size_type>(-1)) constexpr noexcept
Constructs a span for some part of a SoA container.
span(soa_ref soa) explicit constexpr noexcept
Constructs a span for an entire SoA container.

Public functions

auto operator=(const span&) →  span& defaulted
Copy-assignment operator.

Columns

template <auto Column>
auto column() const →  auto* constexpr noexcept
Returns a pointer to the elements of a specific column.
template <typename Func>
void for_each_column(Func&& func) const constexpr noexcept(…)
Invokes a function once for each column data pointer (const overload).

Conversion

template <typename T>
operator span<T>() const constexpr noexcept
Converts between different spans for the same SoA type.

Iterators

template <auto... Cols>
auto begin() const →  soagen::iterator_type<Soa, Cols...> constexpr noexcept
Returns an iterator to the first row viewed by the span.
template <auto... Cols>
auto cbegin() const →  soagen::const_iterator_type<Soa, Cols...> constexpr noexcept
Returns a const iterator to the first row viewed by the span.
template <auto... Cols>
auto cend() const →  soagen::const_iterator_type<Soa, Cols...> constexpr noexcept
Returns a const iterator to one-past-the-last row viewed by the span.
template <auto... Cols>
auto end() const →  soagen::iterator_type<Soa, Cols...> constexpr noexcept
Returns an iterator to one-past-the-last row viewed by the span.

Rows

template <auto... Cols>
auto at(size_type index) const →  soagen::row_type<Soa, Cols...>
Returns the row at the given index.
template <auto... Cols>
auto back() const →  soagen::row_type<Soa, Cols...> noexcept
Returns the last row viewed by the span.
template <auto... Cols>
auto front() const →  soagen::row_type<Soa, Cols...> noexcept
Returns the first row viewed by the span.
auto operator[](size_type index) const →  row_type noexcept
Returns the row at the given index.
template <auto... Cols>
auto row(size_type index) const →  soagen::row_type<Soa, Cols...> noexcept
Returns the row at the given index.

Size

auto empty() const →  bool constexpr noexcept
Returns true if the number of rows viewed by the span is zero.
auto size() const →  size_type constexpr noexcept
Returns the number of rows viewed by the span.

Source SoA containers

auto source() const →  Soa* constexpr noexcept
The source container for this span.
auto source_offset() const →  size_type constexpr noexcept
The base index offset of this span as it relates to the source container.

Spans

auto const_subspan(size_type start, size_type count = static_cast<size_type>(-1)) const →  const_span_type noexcept
Returns a const-qualified subspan of this span.
auto subspan(size_type start, size_type count = static_cast<size_type>(-1)) const →  span_type noexcept
Returns a subspan of this span.

Function documentation

template <typename Soa>
template <typename Func>
void soagen::span::for_each_column(Func&& func) const constexpr noexcept(…)

Invokes a function once for each column data pointer (const overload).

Template parameters
Func

A callable type compatible with one of the following signatures:

Overload resolution is performed in the order listed above.

Parameters
func The callable to invoke.

template <typename Soa>
template <typename T>
soagen::span::operator span<T>() const constexpr noexcept

Converts between different spans for the same SoA type.

This operator allows the following conversions, only some of which are implicit:

FromToexplicitNote
T&const T&gains const
T&&T&&&&
T&&const T&&&&, gains const
T&&const T&&gains const
const T&&const T&&&&
T&T&&YesEquivalent to std::move()
T&const T&&YesEquivalent to std::move()
const T&const T&&YesEquivalent to std::move()

template <typename Soa>
template <auto... Cols>
soagen::row_type<Soa, Cols...> soagen::span::at(size_type index) const

Returns the row at the given index.

Template parameters
Cols Indices of the columns to include in the row. Leave the list empty for all columns.
Exceptions
std::out_of_range

template <typename Soa>
template <auto... Cols>
soagen::row_type<Soa, Cols...> soagen::span::back() const noexcept

Returns the last row viewed by the span.

Template parameters
Cols Indices of the columns to include in the row. Leave the list empty for all columns.

template <typename Soa>
template <auto... Cols>
soagen::row_type<Soa, Cols...> soagen::span::front() const noexcept

Returns the first row viewed by the span.

Template parameters
Cols Indices of the columns to include in the row. Leave the list empty for all columns.

template <typename Soa>
template <auto... Cols>
soagen::row_type<Soa, Cols...> soagen::span::row(size_type index) const noexcept

Returns the row at the given index.

Template parameters
Cols Indices of the columns to include in the row. Leave the list empty for all columns.

template <typename Soa>
Soa* soagen::span::source() const constexpr noexcept

The source container for this span.