mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:27:45 +00:00
AK+Kernel: Make IntrusiveList capable of holding non-raw pointers
This should allow creating intrusive lists that have smart pointers, while remaining free (compared to the impl before this commit) when holding raw pointers :^) As a sidenote, this also adds a `RawPtr<T>` type, which is just equivalent to `T*`. Note that this does not actually use such functionality, but is only expected to pave the way for #6369, to replace NonnullRefPtrVector<T> with intrusive lists. As it is with zero-cost things, this makes the interface a bit less nice by requiring the type name of what an `IntrusiveListNode` holds (and optionally its container, if not RawPtr), and also requiring the type of the container (normally `RawPtr`) on the `IntrusiveList` instance.
This commit is contained in:
parent
fb814ee720
commit
e4412f1f59
11 changed files with 143 additions and 80 deletions
|
@ -49,6 +49,13 @@ constexpr T&& move(T& arg)
|
|||
|
||||
using std::move;
|
||||
|
||||
namespace AK::Detail {
|
||||
template<typename T>
|
||||
struct _RawPtr {
|
||||
using Type = T*;
|
||||
};
|
||||
}
|
||||
|
||||
namespace AK {
|
||||
|
||||
template<typename T>
|
||||
|
@ -122,6 +129,9 @@ constexpr T exchange(T& slot, U&& value)
|
|||
return old_value;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
using RawPtr = typename Detail::_RawPtr<T>::Type;
|
||||
|
||||
}
|
||||
|
||||
using AK::array_size;
|
||||
|
@ -132,4 +142,5 @@ using AK::exchange;
|
|||
using AK::forward;
|
||||
using AK::max;
|
||||
using AK::min;
|
||||
using AK::RawPtr;
|
||||
using AK::swap;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue