[libcxx-commits] [libcxx] [libcxx][string] Allow fancy pointers in basic_string (PR #199264)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Oct 5 02:30:37 PDT 2026
================
@@ -878,16 +880,91 @@ private:
static_assert(sizeof(__short) == (sizeof(value_type) * (__min_cap + 1)), "__short has an unexpected size.");
- union __rep {
+ template <typename _LongT, typename = void>
+ union __rep_t {
__short __s;
- __long __l;
+ _LongT __l;
- __rep() = default;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __rep(__short __r) : __s(__r) {}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __rep(__long __r) : __l(__r) {}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __rep(__uninitialized_tag) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __begin_long_lifetime() {}
+
+ __rep_t() = default;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __rep_t(__short __r) : __s(__r) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __rep_t(_LongT __r) : __l(__r) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __rep_t(__uninitialized_tag) {}
};
+ template <typename _LongT>
+ union __rep_t<_LongT,
+ typename std::enable_if<!is_trivially_constructible<_LongT>::value ||
----------------
frederick-vs-ja wrote:
Let's use `__enable_if_t` here. Also, we shouldn't use `std::` for non-function components unless necessary.
https://github.com/llvm/llvm-project/pull/199264
More information about the libcxx-commits
mailing list