Skip to content

Commit

Permalink
table: check pos when invoking operator[]
Browse files Browse the repository at this point in the history
  • Loading branch information
skypjack committed Apr 30, 2024
1 parent aadbe35 commit a3cea32
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/entt/entity/table.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,13 @@ class basic_table<type_list<Row...>, Allocator>: internal::basic_common_table {
* @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]...);
}

Expand Down

0 comments on commit a3cea32

Please sign in to comment.