[libcxx-commits] [libcxx] [libc++] Ensure that `std::expected` has no tail padding (PR #69673)
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Oct 20 02:08:51 PDT 2023
================
@@ -955,8 +956,17 @@ class expected {
_LIBCPP_NO_UNIQUE_ADDRESS _ErrorType __unex_;
};
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto __calculate_padding() {
+ struct __calc_expected {
+ _LIBCPP_NO_UNIQUE_ADDRESS __union_t<_Tp, _Err> __union_;
+ bool __has_val_;
+ };
+ return sizeof(__calc_expected) - __libcpp_datasizeof<__calc_expected>::value;
----------------
philnik777 wrote:
Why can't we just use `sizeof(expected) - __libcpp_datasizeof<expected>::value`?
https://github.com/llvm/llvm-project/pull/69673
More information about the libcxx-commits
mailing list