Browse Source

table: emplace (back) function

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

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

@@ -356,6 +356,17 @@ public:
         return {std::get<container_for<Row>>(payload).rend()...};
     }
 
+    /**
+     * @brief Appends a row to the end of a table.
+     * @tparam Args Types of arguments to use to construct the row data.
+     * @param args Parameters to use to construct the row data.
+     * @return A reference to the newly created row data.
+     */
+    template<typename... Args>
+    std::tuple<Row &> emplace(Args &&...args) {
+        return std::forward_as_tuple(std::get<container_for<Row>>(payload).emplace_back(std::forward<Args>(args))...);
+    }
+
     /**
      * @brief Returns the row data at specified location.
      * @param pos The row for which to return the data.