AK: Make Vector capable of holding forward-declared types

This is pretty useful for making trees.
This commit is contained in:
Ali Mohammad Pur 2022-03-26 21:29:33 +04:30 committed by Andreas Kling
parent bd6927ecab
commit e21fa158dd
Notes: sideshowbarker 2024-07-17 16:36:36 +09:00

View file

@ -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 };
};