diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-07-25 11:10:28 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-07-25 11:10:28 +0200 |
commit | 6a5446d6ddf009e5fe4970e8509e2b669222a7df (patch) | |
tree | 2b15ae191222ca67c82e9aca3e3a2ff5fd27ab72 | |
parent | 10d120dc852fce62eb11ec5ec80f68374ef01501 (diff) | |
download | serenity-6a5446d6ddf009e5fe4970e8509e2b669222a7df.zip |
AK: Simplify NonnullPtrVector template a bit.
Add an "ElementType" typedef to NonnullOwnPtr and NonnullRefPtr to allow
clients to easily find the pointee type. Then use this to remove a template
argument from NonnullPtrVector. :^)
-rw-r--r-- | AK/NonnullOwnPtr.h | 2 | ||||
-rw-r--r-- | AK/NonnullOwnPtrVector.h | 2 | ||||
-rw-r--r-- | AK/NonnullPtrVector.h | 3 | ||||
-rw-r--r-- | AK/NonnullRefPtr.h | 6 | ||||
-rw-r--r-- | AK/NonnullRefPtrVector.h | 2 |
5 files changed, 9 insertions, 6 deletions
diff --git a/AK/NonnullOwnPtr.h b/AK/NonnullOwnPtr.h index 7c8c7817f2..e9cc114be6 100644 --- a/AK/NonnullOwnPtr.h +++ b/AK/NonnullOwnPtr.h @@ -18,6 +18,8 @@ class WeakPtr; template<typename T> class CONSUMABLE(unconsumed) NonnullOwnPtr { public: + typedef T ElementType; + enum AdoptTag { Adopt }; RETURN_TYPESTATE(unconsumed) diff --git a/AK/NonnullOwnPtrVector.h b/AK/NonnullOwnPtrVector.h index d1d7024b7b..d00644225c 100644 --- a/AK/NonnullOwnPtrVector.h +++ b/AK/NonnullOwnPtrVector.h @@ -6,7 +6,7 @@ namespace AK { template<typename T, int inline_capacity = 0> -class NonnullOwnPtrVector : public NonnullPtrVector<NonnullOwnPtr<T>, T, inline_capacity> +class NonnullOwnPtrVector : public NonnullPtrVector<NonnullOwnPtr<T>, inline_capacity> { }; diff --git a/AK/NonnullPtrVector.h b/AK/NonnullPtrVector.h index 345da11e08..2cc7147c4a 100644 --- a/AK/NonnullPtrVector.h +++ b/AK/NonnullPtrVector.h @@ -4,8 +4,9 @@ namespace AK { -template<typename PtrType, typename T, int inline_capacity = 0> +template<typename PtrType, int inline_capacity = 0> class NonnullPtrVector : public Vector<PtrType, inline_capacity> { + typedef typename PtrType::ElementType T; typedef Vector<PtrType, inline_capacity> Base; public: diff --git a/AK/NonnullRefPtr.h b/AK/NonnullRefPtr.h index 84719fd345..0cbb4ed8f9 100644 --- a/AK/NonnullRefPtr.h +++ b/AK/NonnullRefPtr.h @@ -26,9 +26,9 @@ inline void deref_if_not_null(T* ptr) template<typename T> class CONSUMABLE(unconsumed) NonnullRefPtr { public: - enum AdoptTag { - Adopt - }; + typedef T ElementType; + + enum AdoptTag { Adopt }; RETURN_TYPESTATE(unconsumed) NonnullRefPtr(const T& object) diff --git a/AK/NonnullRefPtrVector.h b/AK/NonnullRefPtrVector.h index 1997e9fe45..38d137108b 100644 --- a/AK/NonnullRefPtrVector.h +++ b/AK/NonnullRefPtrVector.h @@ -6,7 +6,7 @@ namespace AK { template<typename T, int inline_capacity = 0> -class NonnullRefPtrVector : public NonnullPtrVector<NonnullRefPtr<T>, T, inline_capacity> +class NonnullRefPtrVector : public NonnullPtrVector<NonnullRefPtr<T>, inline_capacity> { }; |