Core/MemoryHelper: Add PlacementDestroy
This commit is contained in:
parent
42d5f849f7
commit
ed8deed23c
|
|
@ -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<typename T, typename... Args>
|
||||
T* PlacementNew(T* ptr, Args&&... args);
|
||||
|
||||
template<typename T>
|
||||
void PlacementDestroy(T* ptr);
|
||||
|
||||
class StackAllocation
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -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>(args)...);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Calls the object destructor explicitly
|
||||
*
|
||||
* \param ptr Pointer to a previously constructed pointer on raw memory
|
||||
*/
|
||||
template<typename T>
|
||||
void PlacementDestroy(T* ptr)
|
||||
{
|
||||
ptr->~T();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup core
|
||||
* \class Nz::StackAllocation
|
||||
|
|
|
|||
Loading…
Reference in New Issue