diff --git a/libcxx/include/string b/libcxx/include/string index 4a0aa0ce48e539..ba51e3e9b90d83 100644 --- a/libcxx/include/string +++ b/libcxx/include/string @@ -749,40 +749,32 @@ struct __can_be_converted_to_string_view struct __uninitialized_size_tag {}; struct __init_with_sentinel_tag {}; -#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT + +template +struct __padding { + char __padding_[_PaddingSize]; +}; + +template <> +struct __padding<0> {}; + template struct __short_layout_alternate { _CharT __data_[__min_cap]; - unsigned char __padding_[_Padding]; + _LIBCPP_NO_UNIQUE_ADDRESS __padding __padding_<_Padding>; unsigned char __size_ : 7; unsigned char __is_long_ : 1; }; -template -struct __short_layout_alternate<_CharT, __min_cap, 0> { - _CharT __data_[__min_cap]; - unsigned char __size_ : 7; - unsigned char __is_long_ : 1; -}; -#else template struct __short_layout_classic { struct _LIBCPP_PACKED { unsigned char __is_long_ : 1; unsigned char __size_ : 7; }; - char __padding_[_Padding]; + _LIBCPP_NO_UNIQUE_ADDRESS __padding __padding_<_Padding>; _CharT __data_[__min_cap]; }; -template -struct __short_layout_classic<_CharT, __min_cap, 0> { - struct _LIBCPP_PACKED { - unsigned char __is_long_ : 1; - unsigned char __size_ : 7; - }; - _CharT __data_[__min_cap]; -}; -#endif template class basic_string {