Browse Source

table: check pos when invoking operator[]

Michele Caini 1 year ago
parent
commit
a3cea32f93
1 changed files with 2 additions and 0 deletions
  1. 2 0
      src/entt/entity/table.hpp

+ 2 - 0
src/entt/entity/table.hpp

@@ -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]...);
     }