diff --git a/include/core/state_block/has_state_blocks.h b/include/core/state_block/has_state_blocks.h index 92d924feb37d4592a765bb71cc76a135233035fb..19fa2e37da4f9897e1310efa5923b99e28cc8919 100644 --- a/include/core/state_block/has_state_blocks.h +++ b/include/core/state_block/has_state_blocks.h @@ -94,7 +94,7 @@ template<typename SB, typename ... Args> inline std::shared_ptr<SB> HasStateBlocks::emplaceStateBlock(const std::string& _sb_type, Args&&... _args_of_derived_state_block_constructor) { assert(state_block_map_.count(_sb_type) == 0 && "Trying to add a state block with an existing type!"); - std::shared_ptr<SB> sb(std::forward<Args>(_args_of_derived_state_block_constructor)...); + std::shared_ptr<SB> sb = std::make_shared<SB>(std::forward<Args>(_args_of_derived_state_block_constructor)...); state_block_map_.emplace(_sb_type, sb); return sb; } @@ -103,7 +103,7 @@ template<typename ... Args> inline StateBlockPtr HasStateBlocks::emplaceStateBlock<StateBlock>(const std::string& _sb_type, Args&&... _args_of_base_state_block_constructor) { assert(state_block_map_.count(_sb_type) == 0 && "Trying to add a state block with an existing type!"); - std::shared_ptr<StateBlock> sb(std::forward<Args>(_args_of_base_state_block_constructor)...); + std::shared_ptr<StateBlock> sb = std::make_shared<StateBlock>(std::forward<Args>(_args_of_base_state_block_constructor)...); state_block_map_.emplace(_sb_type, sb); return sb; }