soagen::table class

A table.

Effectively a multi-column std::vector.

Public types

using allocator_type = Allocator
The allocator used by the table.
template <auto Column>
using column_traits = /* ... */
Returns the soagen::column_traits for the column at the specified index.
template <auto Column>
using column_type = /* ... */
Returns the value_type for the column at the specified index.
using const_iterator = soagen::const_iterator_type<table>
Row iterators returned by const-qualified iterator functions.
using const_row_type = soagen::const_row_type<table>
Const row type used by tables.
using const_span_type = soagen::const_span_type<table>
Const-qualified span type.
using difference_type = std::ptrdiff_t
The signed integer difference type used by tables.
using iterator = soagen::iterator_type<table>
Row iterators returned by iterator functions.
using row_type = soagen::row_type<table>
Regular (lvalue-qualified) row type used by tables.
using rvalue_iterator = soagen::rvalue_iterator_type<table>
Row iterators returned by rvalue-qualified iterator functions.
using rvalue_row_type = soagen::rvalue_row_type<table>
Rvalue row type used by tables.
using rvalue_span_type = soagen::rvalue_span_type<table>
Rvalue-qualified span type.
using size_type = std::size_t
The unsigned integer size type used by tables.4.
using span_type = soagen::span_type<table>
Regular (lvalue-qualified) span type.
using table_traits = Traits
The soagen::table_traits for the table.

Public static variables

static constexpr size_t aligned_stride constexpr
The number of rows to advance to maintain the requested alignment for every column.
static constexpr size_type column_count constexpr
The number of columns in the table.

Constructors, destructors, conversion operators

table() defaulted
Default constructor.
table(table&&) defaulted
Move constructor.
table(const table&) defaulted
Copy constructor.
~table() defaulted
Destructor.

Public functions

auto get_allocator() const →  constexpr allocator_type constexpr noexcept
Returns the allocator being used by the table.
auto operator=(table&&) →  table& defaulted
Move-assignment operator.
auto operator=(const table&) →  table& defaulted
Copy-assignment operator.
auto table(const allocator_type& alloc) →  constexpr explicit constexpr noexcept
Constructs with the given allocator.
auto table(allocator_type&& alloc) →  constexpr explicit constexpr noexcept
Constructs with the given allocator.

Adding rows

template <typename... Args>
auto emplace(size_type index, Args && ... args) →  void noexcept(…)
Constructs a new row in-place at an arbitrary position in the table.
template <typename... Args>
auto emplace_back(Args && ... args) →  void noexcept(…)
Constructs a new row in-place at the end of the table.

Capacity

auto allocation_size() const →  constexpr size_t constexpr noexcept
Returns the size of the current underlying buffer allocation in bytes.
auto capacity() const →  constexpr size_type constexpr noexcept
Returns the number of rows that can be held in currently allocated storage.
auto empty() const →  constexpr bool constexpr noexcept
Returns true if the number of rows is zero.
auto max_size() const →  constexpr size_type constexpr noexcept
Returns the maximum possible number of rows.
auto reserve(size_type new_cap) →  void noexcept(…)
Reserves storage for (at least) the given number of rows.
auto shrink_to_fit() →  void noexcept(…)
Frees unused capacity.
auto size() const →  constexpr size_type constexpr noexcept
Returns the current number of rows.

Columns

template <auto Column>
auto column() →  constexpr column_type<Column>* constexpr noexcept
Returns a pointer to the elements of a specific column.
template <auto Column>
auto column() const →  constexpr std::add_const_t<column_type<Column>>* constexpr noexcept
Returns a const-qualified pointer to the elements of a specific column.
auto data() →  constexpr std::byte* constexpr noexcept
Returns a pointer to the raw byte backing array.
auto data() const →  constexpr const std::byte* constexpr noexcept
Returns a const pointer to the raw byte backing array.
template <typename Func>
auto for_each_column(Func&& func) →  constexpr void constexpr noexcept(…)
Invokes a function once for each column data pointer.
template <typename Func>
auto for_each_column(Func&& func) const →  constexpr void constexpr noexcept(…)
Invokes a function once for each column data pointer (const overload).

Comparison

auto operator<(const table& lhs, const table& rhs) →  constexpr bool constexpr noexcept(…)
Returns true if the LHS table is ordered lexicographically less-than the RHS table.
auto operator<=(const table& lhs, const table& rhs) →  constexpr bool constexpr noexcept(…)
Returns true if the LHS table is ordered lexicographically less-than-or-equal-to the RHS table.
auto operator>(const table& lhs, const table& rhs) →  constexpr bool constexpr noexcept(…)
Returns true if the LHS table is ordered lexicographically greater-than the RHS table.
auto operator>=(const table& lhs, const table& rhs) →  constexpr bool constexpr noexcept(…)
Returns true if the LHS table is ordered lexicographically greater-than-or-equal-to the RHS table.

Equality

auto operator!=(const table& lhs, const table& rhs) →  constexpr bool constexpr noexcept(…)
Returns true if not all of the elements in two tables are equal.
auto operator==(const table& lhs, const table& rhs) →  constexpr bool constexpr noexcept(…)
Returns true if all of the elements in two tables are equal.

Iterators

template <auto... Cols>
auto begin() & →  constexpr soagen::iterator_type<table, Cols...> constexpr noexcept
Returns an iterator to the first row in the table.
template <auto... Cols>
auto begin() && →  constexpr soagen::rvalue_iterator_type<table, Cols...> constexpr noexcept
Returns an iterator to the first row in the table.
template <auto... Cols>
auto begin() const & →  constexpr soagen::const_iterator_type<table, Cols...> constexpr noexcept
Returns an iterator to the first row in the table.
template <auto... Cols>
auto cbegin() const →  constexpr soagen::const_iterator_type<table, Cols...> constexpr noexcept
Returns an iterator to the first row in the table.
template <auto... Cols>
auto cend() const →  constexpr soagen::const_iterator_type<table, Cols...> constexpr noexcept
Returns an iterator to one-past-the-last row in the table.
template <auto... Cols>
auto end() & →  constexpr soagen::iterator_type<table, Cols...> constexpr noexcept
Returns an iterator to one-past-the-last row in the table.
template <auto... Cols>
auto end() && →  constexpr soagen::rvalue_iterator_type<table, Cols...> constexpr noexcept
Returns an iterator to one-past-the-last row in the table.
template <auto... Cols>
auto end() const & →  constexpr soagen::const_iterator_type<table, Cols...> constexpr noexcept
Returns an iterator to one-past-the-last row in the table.

Modifiers

auto clear() →  void noexcept
Removes all rows from table.
auto erase(size_type pos) →  void noexcept(…)
Erases the row at the given index.
auto pop_back(size_type num = 1) →  void noexcept(…)
Removes the last row(s) from the table.
auto resize(size_type new_size) →  void noexcept(…)
Resizes the table to the given number of rows.
auto swap(table& other) →  constexpr void constexpr noexcept(…)
Swaps the contents of the table with another.
template <auto A, auto B>
auto swap_columns() →  void noexcept(…)
Swaps two columns.
auto unordered_erase(size_type pos) →  soagen::optional<size_type> noexcept(…)
Erases the row at the given index without preserving order.

Rows

template <auto... Cols>
auto at(size_type index) & →  soagen::row_type<table, Cols...>
Returns the row at the given index.
template <auto... Cols>
auto at(size_type index) && →  soagen::rvalue_row_type<table, Cols...>
Returns the row at the given index (rvalue overload).
template <auto... Cols>
auto at(size_type index) const & →  soagen::const_row_type<table, Cols...>
Returns the row at the given index (const overload).
template <auto... Cols>
auto back() & →  soagen::row_type<table, Cols...> noexcept
Returns the very last row in the table.
template <auto... Cols>
auto back() && →  soagen::row_row_type<table, Cols...> noexcept
Returns the very last row in the table (rvalue overload).
template <auto... Cols>
auto back() const & →  soagen::const_row_type<table, Cols...> noexcept
Returns the very last row in the table (const overload).
template <auto... Cols>
auto front() & →  soagen::row_type<table, Cols...> noexcept
Returns the very first row in the table.
template <auto... Cols>
auto front() && →  soagen::rvalue_row_type<table, Cols...> noexcept
Returns the very first row in the table (rvalue overload).
template <auto... Cols>
auto front() const & →  soagen::const_row_type<table, Cols...> noexcept
Returns the very first row in the table (const overload).
auto operator[](size_type index) & →  row_type noexcept
Returns the row at the given index.
auto operator[](size_type index) && →  rvalue_row_type noexcept
Returns the row at the given index (rvalue overload).
auto operator[](size_type index) const & →  const_row_type noexcept
Returns the row at the given index (const overload).
template <auto... Cols>
auto row(size_type index) & →  soagen::row_type<table, Cols...> noexcept
Returns the row at the given index.
template <auto... Cols>
auto row(size_type index) && →  soagen::rvalue_row_type<table, Cols...> noexcept
Returns the row at the given index.
template <auto... Cols>
auto row(size_type index) const & →  soagen::const_row_type<table, Cols...> noexcept
Returns the row at the given index.

Spans

auto const_subspan(size_type start, size_type count = static_cast<size_type>(-1)) const →  const_span_type noexcept
Returns a const-qualified span of (some part of) the table.
auto subspan(size_type start, size_type count = static_cast<size_type>(-1)) & →  span_type noexcept
Returns a span of (some part of) the table.
auto subspan(size_type start, size_type count = static_cast<size_type>(-1)) && →  rvalue_span_type noexcept
Returns an rvalue-qualified span of (some part of) the table.
auto subspan(size_type start, size_type count = static_cast<size_type>(-1)) const & →  const_span_type noexcept
Returns a const-qualified span of (some part of) the table.

Function documentation

template <typename Traits _1, typename Allocator _2>
constexpr size_t soagen::table::allocation_size() const constexpr noexcept

Returns the size of the current underlying buffer allocation in bytes.

template <typename Traits _1, typename Allocator _2>
constexpr std::byte* soagen::table::data() constexpr noexcept

Returns a pointer to the raw byte backing array.

template <typename Traits _1, typename Allocator _2>
constexpr const std::byte* soagen::table::data() const constexpr noexcept

Returns a const pointer to the raw byte backing array.

template <typename Traits _1, typename Allocator _2>
template <typename Func>
constexpr void soagen::table::for_each_column(Func&& func) constexpr noexcept(…)

Invokes a function once for each column data pointer.

Parameters
func The callable to invoke.

template <typename Traits _1, typename Allocator _2>
template <typename Func>
constexpr void soagen::table::for_each_column(Func&& func) const constexpr noexcept(…)

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

Parameters
func The callable to invoke.

template <typename Traits _1, typename Allocator _2>
void soagen::table::erase(size_type pos) noexcept(…)

Erases the row at the given index.

template <typename Traits _1, typename Allocator _2>
void soagen::table::resize(size_type new_size) noexcept(…)

Resizes the table to the given number of rows.

template <typename Traits _1, typename Allocator _2>
constexpr void soagen::table::swap(table& other) constexpr noexcept(…)

Swaps the contents of the table with another.

template <typename Traits _1, typename Allocator _2>
template <auto A, auto B>
void soagen::table::swap_columns() noexcept(…)

Swaps two columns.

template <typename Traits _1, typename Allocator _2>
soagen::optional<size_type> soagen::table::unordered_erase(size_type pos) noexcept(…)

Erases the row at the given index without preserving order.

Returns The index of the row that was moved into the erased row's position, if any.

This is much faster than erase() because it uses the swap-and-pop idiom: Instead of shifting all the higher rows downward, the last row is moved into the position of the erased one and the size of the table is reduced by 1.

template <typename Traits _1, typename Allocator _2>
template <auto... Cols>
soagen::row_type<table, Cols...> soagen::table::at(size_type index) &

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 Traits _1, typename Allocator _2>
template <auto... Cols>
soagen::rvalue_row_type<table, Cols...> soagen::table::at(size_type index) &&

Returns the row at the given index (rvalue overload).

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 Traits _1, typename Allocator _2>
template <auto... Cols>
soagen::const_row_type<table, Cols...> soagen::table::at(size_type index) const &

Returns the row at the given index (const overload).

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 Traits _1, typename Allocator _2>
template <auto... Cols>
soagen::row_type<table, Cols...> soagen::table::back() & noexcept

Returns the very last row in the table.

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

template <typename Traits _1, typename Allocator _2>
template <auto... Cols>
soagen::row_row_type<table, Cols...> soagen::table::back() && noexcept

Returns the very last row in the table (rvalue overload).

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

template <typename Traits _1, typename Allocator _2>
template <auto... Cols>
soagen::const_row_type<table, Cols...> soagen::table::back() const & noexcept

Returns the very last row in the table (const overload).

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

template <typename Traits _1, typename Allocator _2>
template <auto... Cols>
soagen::row_type<table, Cols...> soagen::table::front() & noexcept

Returns the very first row in the table.

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

template <typename Traits _1, typename Allocator _2>
template <auto... Cols>
soagen::rvalue_row_type<table, Cols...> soagen::table::front() && noexcept

Returns the very first row in the table (rvalue overload).

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

template <typename Traits _1, typename Allocator _2>
template <auto... Cols>
soagen::const_row_type<table, Cols...> soagen::table::front() const & noexcept

Returns the very first row in the table (const overload).

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

template <typename Traits _1, typename Allocator _2>
template <auto... Cols>
soagen::row_type<table, Cols...> soagen::table::row(size_type index) & 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 Traits _1, typename Allocator _2>
template <auto... Cols>
soagen::rvalue_row_type<table, Cols...> soagen::table::row(size_type index) && 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 Traits _1, typename Allocator _2>
template <auto... Cols>
soagen::const_row_type<table, Cols...> soagen::table::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.

Variable documentation

template <typename Traits _1, typename Allocator _2>
static constexpr size_t soagen::table::aligned_stride constexpr

The number of rows to advance to maintain the requested alignment for every column.

The stride size you need to use when iterating through rows of this table such that the starting element for each batch in each column would have the same memory alignment as the value specified for the column-specific alignment.