[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:41 PST 2024
================
@@ -120,7 +123,13 @@ class _LIBCPP_TEMPLATE_VIS reference_wrapper : public __weak_result_type<_Tp> {
#if _LIBCPP_STD_VER >= 17
template <class _Tp>
reference_wrapper(_Tp&) -> reference_wrapper<_Tp>;
-#endif
+
+template <class _Tp>
+struct __tombstone_traits<reference_wrapper<_Tp>> {
+ static constexpr uintptr_t __disengaged_value_ = __builtin_offsetof(reference_wrapper<_Tp>, __f_);
+ static constexpr size_t __is_disengaged_offset_ = 0;
+};
----------------
ldionne wrote:
Most of these traits require a bit of thinking in order to understand what we're taking advantage of. It would be helpful to have a 1-2 line comment for each describing "Here's the invariant of the type and here's the 'unreachable' state of the object we're using to store information".
https://github.com/llvm/llvm-project/pull/98498
More information about the libcxx-commits
mailing list