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/RefPtr.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/RefPtr.h')
-rw-r--r-- | AK/RefPtr.h | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/AK/RefPtr.h b/AK/RefPtr.h index 7619017347..9586e9c11e 100644 --- a/AK/RefPtr.h +++ b/AK/RefPtr.h @@ -12,6 +12,7 @@ #include <AK/Atomic.h> #include <AK/Error.h> #include <AK/Format.h> +#include <AK/Forward.h> #include <AK/NonnullRefPtr.h> #include <AK/StdLibExtras.h> #include <AK/Traits.h> @@ -20,9 +21,6 @@ namespace AK { template<typename T> -class OwnPtr; - -template<typename T> class [[nodiscard]] RefPtr { template<typename U> friend class RefPtr; |