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
1 changed files with 5 additions and 2 deletions

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,11 +70,14 @@ 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)
{
ptr->~T();
if (ptr)
ptr->~T();
}
/*!