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"
|
// This file is part of the "Nazara Engine - Core module"
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
|
|
@ -38,6 +38,9 @@ namespace Nz
|
||||||
template<typename T, typename... Args>
|
template<typename T, typename... Args>
|
||||||
T* PlacementNew(T* ptr, Args&&... args);
|
T* PlacementNew(T* ptr, Args&&... args);
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void PlacementDestroy(T* ptr);
|
||||||
|
|
||||||
class StackAllocation
|
class StackAllocation
|
||||||
{
|
{
|
||||||
public:
|
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"
|
// This file is part of the "Nazara Engine - Core module"
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// 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)...);
|
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
|
* \ingroup core
|
||||||
* \class Nz::StackAllocation
|
* \class Nz::StackAllocation
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue