[libcxx-commits] [libcxx] [libc++] Make list constexpr as part of P3372R3 (PR #129799)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jun 10 08:23:15 PDT 2025
================
@@ -297,14 +297,20 @@ struct __list_node_base {
__base_pointer __prev_;
__base_pointer __next_;
- _LIBCPP_HIDE_FROM_ABI __list_node_base() : __prev_(__self()), __next_(__self()) {}
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_node_base() : __prev_(__self()), __next_(__self()) {}
+ _LIBCPP_CONSTEXPR_SINCE_CXX26
_LIBCPP_HIDE_FROM_ABI explicit __list_node_base(__base_pointer __prev, __base_pointer __next)
: __prev_(__prev), __next_(__next) {}
- _LIBCPP_HIDE_FROM_ABI __base_pointer __self() { return pointer_traits<__base_pointer>::pointer_to(*this); }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __base_pointer __self() {
+ return pointer_traits<__base_pointer>::pointer_to(*this);
+ }
- _LIBCPP_HIDE_FROM_ABI __node_pointer __as_node() { return static_cast<__node_pointer>(__self()); }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __node_pointer __as_node() {
+ return pointer_traits<__node_pointer>::pointer_to(
+ *static_cast<typename pointer_traits<__node_pointer>::element_type*>(this));
----------------
ldionne wrote:
I was going to say "this doesn't handle the case where the pointer is `null`", but I guess since the pointer is `this`, we have other problems if that's the case.
https://github.com/llvm/llvm-project/pull/129799
More information about the libcxx-commits
mailing list