[libcxx-commits] [libcxx] [libc++] Make forward_list constexpr as part of P3372R3 (PR #129435)

Peng Liu via libcxx-commits libcxx-commits at lists.llvm.org
Fri Mar 7 10:06:46 PST 2025


================
@@ -295,9 +295,12 @@ struct __forward_node_traits {
                 "the _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB macro to silence this diagnostic.");
 #  endif
 
-  _LIBCPP_HIDE_FROM_ABI static __begin_node_pointer __as_iter_node(__begin_node_pointer __p) { return __p; }
-  _LIBCPP_HIDE_FROM_ABI static __begin_node_pointer __as_iter_node(__node_pointer __p) {
-    return static_cast<__begin_node_pointer>(static_cast<__void_pointer>(__p));
+  _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI static __begin_node_pointer
+  __as_iter_node(__begin_node_pointer __p) {
+    return __p;
+  }
+  _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI static __begin_node_pointer __as_iter_node(__node_pointer __p) {
+    return std::__static_fancy_pointer_cast<__begin_node_pointer>(__p);
----------------
winner245 wrote:

@philnik777 I am not sure if I understood your comment correctly in the first place. Were you suggesting me clean up the unnecessary `static_cast`s before this one? If so, I've submitted a separate patch #130310 for that. 

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


More information about the libcxx-commits mailing list