Browse Source

table: operator[] overloads

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

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

@@ -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(), ...);