Core/MemoryHelper: Make PlacementDestroy a no-op on null pointers

This commit is contained in:
Jérôme Leclercq
2018-01-05 16:09:25 +01:00
parent eb9bc18b45
commit e8d519dad7

View File

@@ -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
@@ -70,10 +70,13 @@ namespace Nz
* \brief Calls the object destructor explicitly
*
* \param ptr Pointer to a previously constructed pointer on raw memory
*
* \remark This does not deallocate memory, and is a no-op on a null pointer
*/
template<typename T>
void PlacementDestroy(T* ptr)
{
if (ptr)
ptr->~T();
}