table: check pos when invoking operator[]

This commit is contained in:
Michele Caini
2024-04-30 11:02:56 +02:00
parent aadbe3501e
commit a3cea32f93

View File

@@ -397,11 +397,13 @@ public:
* @return The row data at specified location.
*/
[[nodiscard]] std::tuple<const Row &...> operator[](const size_type pos) const {
ENTT_ASSERT(pos < size(), "Index out of bounds");
return std::forward_as_tuple(std::get<container_for<Row>>(payload.first())[pos]...);
}
/*! @copydoc operator[] */
[[nodiscard]] std::tuple<Row &...> operator[](const size_type pos) {
ENTT_ASSERT(pos < size(), "Index out of bounds");
return std::forward_as_tuple(std::get<container_for<Row>>(payload.first())[pos]...);
}