@@ -1122,20 +1122,18 @@ template <typename T> struct alignas(T) SmallVectorStorage<T, 0> {};
11221122// / `sizeof(SmallVector<T, 0>)`.
11231123template <typename T, unsigned N> class LLVM_GSL_OWNER SmallVector;
11241124
1125- // / Helper class for calculating the default number of inline elements for
1125+ // / Helper function for calculating the default number of inline elements for
11261126// / `SmallVector<T>`.
1127- // /
1128- // / This should be migrated to a constexpr function when our minimum
1129- // / compiler support is enough for multi-statement constexpr functions.
1130- template <typename T> struct CalculateSmallVectorDefaultInlinedElements {
1127+ template <typename T>
1128+ constexpr size_t calculateSmallVectorDefaultInlinedElements () {
11311129 // Parameter controlling the default number of inlined elements
11321130 // for `SmallVector<T>`.
11331131 //
11341132 // The default number of inlined elements ensures that
11351133 // 1. There is at least one inlined element.
11361134 // 2. `sizeof(SmallVector<T>) <= kPreferredSmallVectorSizeof` unless
11371135 // it contradicts 1.
1138- static constexpr size_t kPreferredSmallVectorSizeof = 64 ;
1136+ constexpr size_t kPreferredSmallVectorSizeof = 64 ;
11391137
11401138 // static_assert that sizeof(T) is not "too big".
11411139 //
@@ -1168,12 +1166,11 @@ template <typename T> struct CalculateSmallVectorDefaultInlinedElements {
11681166
11691167 // Discount the size of the header itself when calculating the maximum inline
11701168 // bytes.
1171- static constexpr size_t PreferredInlineBytes =
1169+ constexpr size_t PreferredInlineBytes =
11721170 kPreferredSmallVectorSizeof - sizeof (SmallVector<T, 0 >);
1173- static constexpr size_t NumElementsThatFit = PreferredInlineBytes / sizeof (T);
1174- static constexpr size_t value =
1175- NumElementsThatFit == 0 ? 1 : NumElementsThatFit;
1176- };
1171+ constexpr size_t NumElementsThatFit = PreferredInlineBytes / sizeof (T);
1172+ return NumElementsThatFit == 0 ? 1 : NumElementsThatFit;
1173+ }
11771174
11781175// / This is a 'vector' (really, a variable-sized array), optimized
11791176// / for the case when the array is small. It contains some number of elements
@@ -1192,7 +1189,7 @@ template <typename T> struct CalculateSmallVectorDefaultInlinedElements {
11921189// /
11931190// / \see https://llvm.org/docs/ProgrammersManual.html#llvm-adt-smallvector-h
11941191template <typename T,
1195- unsigned N = CalculateSmallVectorDefaultInlinedElements <T>::value >
1192+ unsigned N = calculateSmallVectorDefaultInlinedElements <T>() >
11961193class LLVM_GSL_OWNER SmallVector : public SmallVectorImpl<T>,
11971194 SmallVectorStorage<T, N> {
11981195public:
0 commit comments