mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03: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
Notes:
sideshowbarker
2024-07-17 16:36:36 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/e21fa158dd Pull-request: https://github.com/SerenityOS/serenity/pull/13310 Reviewed-by: https://github.com/IdanHo
18
AK/Vector.h
18
AK/Vector.h
@ -793,7 +793,23 @@ private:
|
||||
size_t m_size { 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 };
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user