[libcxx-commits] [libcxx] [libc++][string] Remove potential non-trailing 0-length array (PR #105865)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Aug 27 14:38:26 PDT 2024
================
@@ -748,6 +748,41 @@ struct __can_be_converted_to_string_view
struct __uninitialized_size_tag {};
struct __init_with_sentinel_tag {};
+#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
+template <class _CharT, size_t __min_cap, size_t _Padding = sizeof(_CharT) - 1>
+struct __short_impl {
----------------
ldionne wrote:
I would like to do this:
```c++
// always define both of these classes
template <class _CharT, size_t __min_cap, size_t _Padding = sizeof(_CharT) - 1>
struct __short_layout_alternate { ... };
template <class _CharT, size_t __min_cap, size_t _Padding = sizeof(_CharT) - 1>
struct __short_layout_classic { ... };
// now inside basic_string
#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
using __short = __short_layout_alternate <value_type, __min_cap>;
#else
using __short = __short_layout_classic <value_type, __min_cap>;
#endif
```
This reduces the scope of the conditional code and IMO makes things easier to understand.
https://github.com/llvm/llvm-project/pull/105865
More information about the libcxx-commits
mailing list