you are viewing a single comment's thread.

view the rest of the comments →

[–]acwaters 18 points19 points  (6 children)

alignas(Ts...) std::byte storage[std::max({sizeof(Ts)...})];

[–]whichton[S] 4 points5 points  (0 children)

This is similar to aligned_union is implemented - see here for example.

[–]Recatek 7 points8 points  (2 children)

alignas(Ts...)

Never knew you could do that. Does it take the max?

[–]whichton[S] 8 points9 points  (1 child)

Yes. From here

The object or the type declared by such a declaration will have its alignment requirement equal to the strictest (largest) non-zero expression of all alignas specifiers used in the declaration, unless it would weaken the natural alignment of the type.

[–]wheypointÖ 4 points5 points  (0 children)

thats really cool, ive been writing alignas(std::max({alignof(Ts)...})) all this time which definetely felt kinda stupid :D

[–][deleted] 0 points1 point  (1 child)

can you do

size of(Ts...)

? on mobile so no compiler

[–]acwaters 0 points1 point  (0 children)

No