[libcxx-commits] [libcxx] [libcxx] address of all the things. (PR #102832)

Nhat Nguyen via libcxx-commits libcxx-commits at lists.llvm.org
Sun Aug 11 15:03:58 PDT 2024


https://github.com/changkhothuychung created https://github.com/llvm/llvm-project/pull/102832

Fix #100248
LWG3131: addressof all the things

>From c2c0203c535eea46b74a48ff1e4b447bf810f82e Mon Sep 17 00:00:00 2001
From: changkhothuychung <nhat7203 at gmail.com>
Date: Sun, 11 Aug 2024 18:03:04 -0400
Subject: [PATCH] add addressof for string data()

---
 libcxx/include/string | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libcxx/include/string b/libcxx/include/string
index 9a52ab6aef41e8..8c2da057bd60c6 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -1630,11 +1630,11 @@ public:
 
   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* c_str() const _NOEXCEPT { return data(); }
   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* data() const _NOEXCEPT {
-    return std::__to_address(__get_pointer());
+    return std::addressof(__get_pointer());
   }
 #if _LIBCPP_STD_VER >= 17
   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 value_type* data() _NOEXCEPT {
-    return std::__to_address(__get_pointer());
+    return std::addressof(__get_pointer());
   }
 #endif
 



More information about the libcxx-commits mailing list