diff --git a/source/util/small_vector.h b/source/util/small_vector.h index 648a34824f5..d29f423253a 100644 --- a/source/util/small_vector.h +++ b/source/util/small_vector.h @@ -46,7 +46,7 @@ class SmallVector { SmallVector() : size_(0), - small_data_(reinterpret_cast(buffer)), + small_data_(reinterpret_cast(buffer.data())), large_data_(nullptr) {} SmallVector(const SmallVector& that) : SmallVector() { *this = that; } @@ -461,15 +461,14 @@ class SmallVector { // The number of elements in |small_data_| that have been constructed. size_t size_; + // The actual data used to store the array elements. It must never be used + // directly, but must only be accessed through |small_data_|. + alignas(T) std::array buffer; + // The pointed used to access the array of elements when the number of // elements is small. T* small_data_; - // The actual data used to store the array elements. It must never be used - // directly, but must only be accessed through |small_data_|. - typename std::aligned_storage::value>::type - buffer[small_size]; - // A pointer to a vector that is used to store the elements of the vector when // this size exceeds |small_size|. If |large_data_| is nullptr, then the data // is stored in |small_data_|. Otherwise, the data is stored in