diff options
Diffstat (limited to 'AK/OwnPtrWithCustomDeleter.h')
-rw-r--r-- | AK/OwnPtrWithCustomDeleter.h | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/AK/OwnPtrWithCustomDeleter.h b/AK/OwnPtrWithCustomDeleter.h deleted file mode 100644 index f9968810ed..0000000000 --- a/AK/OwnPtrWithCustomDeleter.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2022, Lucas Chollet <lucas.chollet@free.fr> - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#pragma once - -#include <AK/Function.h> -#include <AK/Noncopyable.h> -#include <AK/StdLibExtras.h> - -template<typename T> -struct OwnPtrWithCustomDeleter { - AK_MAKE_NONCOPYABLE(OwnPtrWithCustomDeleter); - -public: - OwnPtrWithCustomDeleter(T* ptr, Function<void(T*)> deleter) - : m_ptr(ptr) - , m_deleter(move(deleter)) - { - } - - OwnPtrWithCustomDeleter(OwnPtrWithCustomDeleter&& other) - { - swap(m_ptr, other.m_ptr); - swap(m_deleter, other.m_deleter); - }; - - ~OwnPtrWithCustomDeleter() - { - if (m_ptr) { - VERIFY(m_deleter); - m_deleter(m_ptr); - } - } - -private: - T* m_ptr { nullptr }; - Function<void(T*)> m_deleter {}; -}; |