[libcxx-commits] [libcxx] [libc++] Add tombstone traits to use in optional, variant (PR #98498)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jul 11 09:31:52 PDT 2024


================
@@ -686,6 +686,12 @@ template <class _CharT, class _Traits>
 inline constexpr bool ranges::enable_borrowed_range<basic_string_view<_CharT, _Traits> > = true;
 #endif // _LIBCPP_STD_VER >= 20
 
+template <class _CharT, class _Traits>
+struct __tombstone_memory_layout<basic_string_view<_CharT, _Traits>> {
+  static constexpr size_t __disengaged_value_     = basic_string_view<_CharT, _Traits>::npos;
----------------
ldionne wrote:

I think `npos` is a valid size for a `string_view`. It's somewhat academic but I don't think this specific optimization is valid.

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


More information about the libcxx-commits mailing list