[libcxx-commits] [libcxx] [lldb] [libcxx] adds size-based `__split_buffer` representation to unstable ABI (PR #139632)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Thu Aug 7 03:03:49 PDT 2025


================
@@ -428,50 +630,87 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::shrink_to_fi
   }
 }
 
-template <class _Tp, class _Allocator>
+// Need to use this because C++03 doesn't permit constexpr if :(
+template <bool>
+struct __maybe_update_sentinel;
+
+template <>
+struct __maybe_update_sentinel<true> {
+  template <class _SplitBuffer, class _DifferenceType>
+  _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI static void
+  __update_size(_SplitBuffer& __data, _DifferenceType __d) {
+    __data.__update_sentinel(__data.size() + __d);
+  }
+
+  template <class _SplitBuffer>
+  _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI static void __update_end(_SplitBuffer& __data) {
+    __data.update_sentinel(__data.end() + 1);
+  }
+};
+
+template <>
+struct __maybe_update_sentinel<false> {
+  template <class _SplitBuffer, class _DifferenceType>
+  _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI static void __update_size(_SplitBuffer&, _DifferenceType) {}
+
+  template <class _SplitBuffer>
+  _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI static void __update_end(_SplitBuffer&) {}
+};
----------------
philnik777 wrote:

This looks like it should be part of the layout class. The whole point of that is that we have a uniform interface, which we apparently don't quite have.

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


More information about the libcxx-commits mailing list