@@ -80,6 +80,7 @@ using EnableIfCallable = std::enable_if_t<std::disjunction<
80
80
template <typename ReturnT, typename ... ParamTs> class UniqueFunctionBase {
81
81
protected:
82
82
static constexpr size_t InlineStorageSize = sizeof (void *) * 3 ;
83
+ static constexpr size_t InlineStorageAlign = alignof (void *);
83
84
84
85
template <typename T, class = void >
85
86
struct IsSizeLessThanThresholdT : std::false_type {};
@@ -161,7 +162,8 @@ template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
161
162
// provide three pointers worth of storage here.
162
163
// This is mutable as an inlined `const unique_function<void() const>` may
163
164
// still modify its own mutable members.
164
- alignas (void *) mutable std::byte InlineStorage[InlineStorageSize];
165
+ alignas (InlineStorageAlign) mutable std::byte
166
+ InlineStorage[InlineStorageSize];
165
167
} StorageUnion;
166
168
167
169
// A compressed pointer to either our dispatching callback or our table of
@@ -262,7 +264,7 @@ template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
262
264
bool IsInlineStorage = true ;
263
265
void *CallableAddr = getInlineStorage ();
264
266
if (sizeof (CallableT) > InlineStorageSize ||
265
- alignof (CallableT) > alignof ( decltype (StorageUnion. InlineStorage )) ) {
267
+ alignof (CallableT) > InlineStorageAlign ) {
266
268
IsInlineStorage = false ;
267
269
// Allocate out-of-line storage. FIXME: Use an explicit alignment
268
270
// parameter in C++17 mode.
0 commit comments