[llvm] [libc++] Ensure that `std::expected` has no tail padding (PR #69673)

Jan Kokemüller via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 21 02:56:26 PDT 2023


jiixyj wrote:

I've tried to implement the "`repr` struct" strategy. On mutating operations, the whole `repr` struct is teared down and recreated if needed. This has also the nice side effect that the `__has_value_` flag is never manually mutated any longer. The state of the union and the value of the `__has_value_` flag are guaranteed to be kept in sync by `repr`'s constructors.

Internally, the `repr` struct still needs to call `std::construct_at`/`std::destroy_at` sometimes on its '[[no_unique_address]]` members. Not sure if that is OK...

https://github.com/llvm/llvm-project/pull/69673


More information about the llvm-commits mailing list