template <typename Traits, typename Allocator = soagen::allocator>
soagen::table class

A table.

Template parameters
Traits The soagen::table_traits for the table.
Allocator The allocator used by the 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::iterator_type<table && >
Row iterators returned by rvalue-qualified iterator functions.
using rvalue_row_type = soagen::row_type<table && >
Rvalue row type used by tables.
using rvalue_span_type = soagen::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 size_t aligned_stride constexpr
The number of rows to advance to maintain the requested alignment for every column.
static 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(const allocator_type& alloc) explicit constexpr noexcept
Constructs with the given allocator.
table(allocator_type&& alloc) explicit constexpr noexcept
Constructs with the given allocator.
~table() defaulted
Destructor.

Public functions

auto get_allocator() const -> 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.

Adding rows

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

Capacity

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

Columns

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

Comparison

auto operator<(const table& lhs, const table& rhs) -> 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) -> 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) -> 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) -> 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) -> bool constexpr noexcept(…)
Returns true if not all of the elements in two tables are equal.
auto operator==(const table& lhs, const table& rhs) -> bool constexpr noexcept(…)
Returns true if all of the elements in two tables are equal.

Iterators

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

Modifiers

void clear() noexcept
Removes all rows from table.
void erase(size_type pos) noexcept(…)
Erases the row at the given index.
void pop_back(size_type num = 1) noexcept(…)
Removes the last row(s) from the table.
void resize(size_type new_size) noexcept(…)
Resizes the table to the given number of rows.
void swap(table& other) constexpr noexcept(…)
Swaps the contents of the table with another.
template <auto A, auto B>
void swap_columns() 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::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_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::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::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, typename Allocator>
size_t soagen::table::allocation_size() const constexpr noexcept

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

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

Returns a pointer to the raw byte backing array.

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

Returns a const pointer to the raw byte backing array.

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

Invokes a function once for each column data pointer.

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 Traits, typename Allocator>
template <typename Func>
void soagen::table::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 Traits, typename Allocator>
void soagen::table::erase(size_type pos) noexcept(…)

Erases the row at the given index.

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

Resizes the table to the given number of rows.

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

Swaps the contents of the table with another.

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

Swaps two columns.

template <typename Traits, typename Allocator>
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, typename Allocator>
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, typename Allocator>
template <auto... Cols>
soagen::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, typename Allocator>
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, typename Allocator>
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, typename Allocator>
template <auto... Cols>
soagen::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, typename Allocator>
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, typename Allocator>
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, typename Allocator>
template <auto... Cols>
soagen::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, typename Allocator>
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, typename Allocator>
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, typename Allocator>
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, typename Allocator>
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, typename Allocator>
static 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.