mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:37:44 +00:00
AK: Make Vector capable of holding forward-declared types
This is pretty useful for making trees.
This commit is contained in:
parent
bd6927ecab
commit
e21fa158dd
1 changed files with 17 additions and 1 deletions
18
AK/Vector.h
18
AK/Vector.h
|
@ -793,7 +793,23 @@ private:
|
||||||
size_t m_size { 0 };
|
size_t m_size { 0 };
|
||||||
size_t m_capacity { 0 };
|
size_t m_capacity { 0 };
|
||||||
|
|
||||||
alignas(StorageType) unsigned char m_inline_buffer_storage[sizeof(StorageType) * inline_capacity];
|
static constexpr size_t storage_size()
|
||||||
|
{
|
||||||
|
if constexpr (inline_capacity == 0)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return sizeof(StorageType) * inline_capacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
static constexpr size_t storage_alignment()
|
||||||
|
{
|
||||||
|
if constexpr (inline_capacity == 0)
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return alignof(StorageType);
|
||||||
|
}
|
||||||
|
|
||||||
|
alignas(storage_alignment()) unsigned char m_inline_buffer_storage[storage_size()];
|
||||||
StorageType* m_outline_buffer { nullptr };
|
StorageType* m_outline_buffer { nullptr };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue