If I understand it correctly, the main advantage of the std::aligned_storage
is that it manages the alignment. Also it can be copied with memcpy()
and can be used with POD types.
But!
1) The POD types are aligned by compiler by default and we can override this compiler's alignment using #pragma pack(push, 1)
2) We can copy POD with memcpy()
by default (we shouldn't do something for this ability)
So I don't really understand why do we need std::aligned_storage
?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With