From fd60c0280440da053948f7500657ae65b94036bf Mon Sep 17 00:00:00 2001 From: max-001 Date: Thu, 7 Nov 2024 09:45:08 +0100 Subject: Improved RAII --- src/crepe/ComponentManager.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/crepe/ComponentManager.hpp') diff --git a/src/crepe/ComponentManager.hpp b/src/crepe/ComponentManager.hpp index eac38fc..e52b679 100644 --- a/src/crepe/ComponentManager.hpp +++ b/src/crepe/ComponentManager.hpp @@ -30,8 +30,7 @@ T & ComponentManager::add_component(uint32_t id, Args &&... args) { // Create a new component of type T (arguments directly forwarded). The // constructor must be called by ComponentManager. - T * instance_pointer = new T(id, forward(args)...); - unique_ptr instance = unique_ptr(instance_pointer); + unique_ptr instance = unique_ptr(new T(id, forward(args)...)); // Check if the vector size is not greater than get_instances_max if (instance->get_instances_max() != -1 -- cgit v1.2.3