16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-17 23:39:18 +02:00

SafeDelete template type set to pointer

This commit is contained in:
docentYT
2026-05-01 18:47:52 +02:00
parent 0c19bd4507
commit 2d1616af60

View File

@@ -230,13 +230,14 @@ std::ptrdiff_t len_common_prefix(std::string_view a, std::string_view b);
bool contains(std::string_view const String, std::string_view Substring);
bool contains(std::string_view const String, char Character);
template <typename Type_> void SafeDelete(Type_ &Pointer)
// TODO: Ideally unique_ptr should be used instead of this (not safe) inline functions
template <typename T> inline void SafeDelete(T* &Pointer)
{
delete Pointer;
Pointer = nullptr;
}
template <typename Type_> void SafeDeleteArray(Type_ &Pointer)
template <typename T> inline void SafeDeleteArray(T *&Pointer)
{
delete[] Pointer;
Pointer = nullptr;