table: operator[] overloads

This commit is contained in:
Michele Caini
2024-04-23 13:22:22 +02:00
parent 9f7668071d
commit 12e886340c

View File

@@ -356,6 +356,20 @@ public:
return {std::get<container_for<Row>>(payload).rend()...};
}
/**
* @brief Returns the row data at specified location.
* @param pos The row for which to return the data.
* @return The row data at specified location.
*/
[[nodiscard]] std::tuple<const Row &...> operator[](const size_type pos) const {
return std::forward_as_tuple(std::get<container_for<Row>>(payload)[pos]...);
}
/*! @copydoc operator[] */
[[nodiscard]] std::tuple<Row &...> operator[](const size_type pos) {
return std::forward_as_tuple(std::get<container_for<Row>>(payload)[pos]...);
}
/*! @brief Clears a table. */
void clear() {
(std::get<container_for<Row>>(payload).clear(), ...);