diff --git a/include/etl/memory.h b/include/etl/memory.h index 0be98a1b..0f6df281 100644 --- a/include/etl/memory.h +++ b/include/etl/memory.h @@ -417,6 +417,16 @@ namespace etl ::new (p) T(value); } + //***************************************************************************** + /// Copy construct an item at address p. + ///\ingroup memory + //***************************************************************************** + template + void create_copy_at(T* p, T&& value) + { + ::new (p) T(std::move(value)); + } + //***************************************************************************** /// Copy construct an item at address p. ///\ingroup memory @@ -462,6 +472,17 @@ namespace etl return *reinterpret_cast(p); } + //***************************************************************************** + /// Construct an item at address p. + ///\ingroup memory + //***************************************************************************** + template + T& make_copy_at(T* p, T&& other) + { + ::new (p) T(std::move(other)); + return *reinterpret_cast(p); + } + //***************************************************************************** /// Construct an item at address p. ///\ingroup memory @@ -485,6 +506,17 @@ namespace etl return *reinterpret_cast(p); } + //***************************************************************************** + /// Construct an item at address p. + ///\ingroup memory + //***************************************************************************** + template + T& make_value_at(T* p, TParameter&& value) + { + ::new (p) T(std::move(value)); + return *reinterpret_cast(p); + } + //***************************************************************************** /// Construct an item at address p. ///\ingroup memory