diff --git a/include/Nazara/Core/MemoryHelper.hpp b/include/Nazara/Core/MemoryHelper.hpp index 6f53a012f..dc1bcc475 100644 --- a/include/Nazara/Core/MemoryHelper.hpp +++ b/include/Nazara/Core/MemoryHelper.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -38,6 +38,9 @@ namespace Nz template T* PlacementNew(T* ptr, Args&&... args); + template + void PlacementDestroy(T* ptr); + class StackAllocation { public: diff --git a/include/Nazara/Core/MemoryHelper.inl b/include/Nazara/Core/MemoryHelper.inl index f7380e1b8..dcee8ca4e 100644 --- a/include/Nazara/Core/MemoryHelper.inl +++ b/include/Nazara/Core/MemoryHelper.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -64,6 +64,17 @@ namespace Nz return new (ptr) T(std::forward(args)...); } + /*! + * \brief Calls the object destructor explicitly + * + * \param ptr Pointer to a previously constructed pointer on raw memory + */ + template + void PlacementDestroy(T* ptr) + { + ptr->~T(); + } + /*! * \ingroup core * \class Nz::StackAllocation