QVarLengthArray: avoid std::aligned_storage (deprecated in C++23)
Add some scaffolding to prevent us from running into BC issues due to
the underspecified nature of std::aligned_storage.
Qt 5.15 uses a union { char[], double, qint64 } instead of
std::aligned_storage, so doesn't need the fix.
References:
- https://github.com/cplusplus/papers/issues/197
- wg21.link/p1413
Task-number: QTBUG-99122
Pick-to: 6.3 6.2
Change-Id: I212be7000376c2db33b8cb244a6e862cc4dad544
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
parent
9440c1a1fc
commit
9a7d2a7acf
|
|
@ -65,10 +65,18 @@ QT_BEGIN_NAMESPACE
|
|||
template <size_t Size, size_t Align, qsizetype Prealloc>
|
||||
class QVLAStorage
|
||||
{
|
||||
template <size_t> class print;
|
||||
protected:
|
||||
~QVLAStorage() = default;
|
||||
|
||||
std::aligned_storage_t<Size, Align> array[Prealloc];
|
||||
alignas(Align) char array[Prealloc * (Align > Size ? Align : Size)];
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_DEPRECATED
|
||||
// ensure we maintain BC: std::aligned_storage_t was only specified by a
|
||||
// minimum size, but for BC we need the substitution to be exact in size:
|
||||
static_assert(std::is_same_v<print<sizeof(std::aligned_storage_t<Size, Align>[Prealloc])>,
|
||||
print<sizeof(array)>>);
|
||||
QT_WARNING_POP
|
||||
};
|
||||
|
||||
class QVLABaseBase
|
||||
|
|
|
|||
Loading…
Reference in New Issue