mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:07:34 +00:00
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. :^)
This commit is contained in:
parent
10d120dc85
commit
6a5446d6dd
5 changed files with 9 additions and 6 deletions
|
@ -18,6 +18,8 @@ class WeakPtr;
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class CONSUMABLE(unconsumed) NonnullOwnPtr {
|
class CONSUMABLE(unconsumed) NonnullOwnPtr {
|
||||||
public:
|
public:
|
||||||
|
typedef T ElementType;
|
||||||
|
|
||||||
enum AdoptTag { Adopt };
|
enum AdoptTag { Adopt };
|
||||||
|
|
||||||
RETURN_TYPESTATE(unconsumed)
|
RETURN_TYPESTATE(unconsumed)
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
namespace AK {
|
namespace AK {
|
||||||
|
|
||||||
template<typename T, int inline_capacity = 0>
|
template<typename T, int inline_capacity = 0>
|
||||||
class NonnullOwnPtrVector : public NonnullPtrVector<NonnullOwnPtr<T>, T, inline_capacity>
|
class NonnullOwnPtrVector : public NonnullPtrVector<NonnullOwnPtr<T>, inline_capacity>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
|
|
||||||
namespace AK {
|
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> {
|
class NonnullPtrVector : public Vector<PtrType, inline_capacity> {
|
||||||
|
typedef typename PtrType::ElementType T;
|
||||||
typedef Vector<PtrType, inline_capacity> Base;
|
typedef Vector<PtrType, inline_capacity> Base;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -26,9 +26,9 @@ inline void deref_if_not_null(T* ptr)
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class CONSUMABLE(unconsumed) NonnullRefPtr {
|
class CONSUMABLE(unconsumed) NonnullRefPtr {
|
||||||
public:
|
public:
|
||||||
enum AdoptTag {
|
typedef T ElementType;
|
||||||
Adopt
|
|
||||||
};
|
enum AdoptTag { Adopt };
|
||||||
|
|
||||||
RETURN_TYPESTATE(unconsumed)
|
RETURN_TYPESTATE(unconsumed)
|
||||||
NonnullRefPtr(const T& object)
|
NonnullRefPtr(const T& object)
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
namespace AK {
|
namespace AK {
|
||||||
|
|
||||||
template<typename T, int inline_capacity = 0>
|
template<typename T, int inline_capacity = 0>
|
||||||
class NonnullRefPtrVector : public NonnullPtrVector<NonnullRefPtr<T>, T, inline_capacity>
|
class NonnullRefPtrVector : public NonnullPtrVector<NonnullRefPtr<T>, inline_capacity>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue