[libcxx-commits] [libcxx] [libc++] Add tombstone traits and use them in optional (PR #98498)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Dec 2 07:02:40 PST 2024
================
@@ -112,8 +113,17 @@ private:
friend bool has_facet(const locale&) _NOEXCEPT;
template <class _Facet>
friend const _Facet& use_facet(const locale&);
+
+ friend struct __tombstone_traits<locale>;
};
+#if _LIBCPP_STD_VER >= 17
+template <>
+struct __tombstone_traits<locale> : __tombstone_traits_assume_aligned_pointer {
+ static_assert(__builtin_offsetof(locale, __locale_) == 0);
----------------
ldionne wrote:
Just to be safe, we might also want to `static_assert` that the size of `std::locale` is exactly the size of a pointer. While the code would still work without that assumption, I think we'd want to be notified if we change the layout of `locale` (e.g. under some ABI config) and revisit whether these `tombstone_traits` still make sense as-is.
https://github.com/llvm/llvm-project/pull/98498
More information about the libcxx-commits
mailing list