diff options
author | Lenny Maiorani <lenny@serenityos.org> | 2022-12-15 20:51:55 -0700 |
---|---|---|
committer | Tim Flynn <trflynn89@pm.me> | 2022-12-17 16:00:08 -0500 |
commit | f2336d0144fbbf6d72bd1eeaa34667dc4eb76760 (patch) | |
tree | a1f1c53b9257a11baf2f2e382ddf2f6bd9b2c27e /AK/Forward.h | |
parent | 53133b4359caf5a8cc5f30d1313759ea4a017870 (diff) | |
download | serenity-f2336d0144fbbf6d72bd1eeaa34667dc4eb76760.zip |
AK+Everywhere: Move custom deleter capability to OwnPtr
`OwnPtrWithCustomDeleter` was a decorator which provided the ability
to add a custom deleter to `OwnPtr` by wrapping and taking the deleter
as a run-time argument to the constructor. This solution means that no
additional space is needed for the `OwnPtr` because it doesn't need to
store a pointer to the deleter, but comes at the cost of having an
extra type that stores a pointer for every instance.
This logic is moved directly into `OwnPtr` by adding a template
argument that is defaulted to the default deleter for the type. This
means that the type itself stores the pointer to the deleter instead
of every instance and adds some type safety by encoding the deleter in
the type itself instead of taking a run-time argument.
Diffstat (limited to 'AK/Forward.h')
-rw-r--r-- | AK/Forward.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/AK/Forward.h b/AK/Forward.h index 86b288a318..c92787928b 100644 --- a/AK/Forward.h +++ b/AK/Forward.h @@ -6,6 +6,7 @@ #pragma once +#include <AK/DefaultDelete.h> #include <AK/Types.h> namespace AK { @@ -133,7 +134,7 @@ class LockRefPtr; template<typename T> class RefPtr; -template<typename T> +template<typename T, typename TDeleter = DefaultDelete<T>> class OwnPtr; template<typename T> |