[libc++] Implement P1147R1 (Printing volatile T*)

Differential Revision: https://reviews.llvm.org/D113482

GitOrigin-RevId: f0d5a60fc1a40f335595ae12274b7e875479ea7f
diff --git a/include/ostream b/include/ostream
index e0aa18f..1b3dd54 100644
--- a/include/ostream
+++ b/include/ostream
@@ -55,6 +55,7 @@
     basic_ostream& operator<<(double f);
     basic_ostream& operator<<(long double f);
     basic_ostream& operator<<(const void* p);
+    basic_ostream& operator<<(const volatile void* val); // C++23
     basic_ostream& operator<<(basic_streambuf<char_type,traits>* sb);
     basic_ostream& operator<<(nullptr_t);
 
@@ -210,6 +211,14 @@
     basic_ostream& operator<<(double __f);
     basic_ostream& operator<<(long double __f);
     basic_ostream& operator<<(const void* __p);
+
+#if _LIBCPP_STD_VER > 20
+    _LIBCPP_HIDE_FROM_ABI
+    basic_ostream& operator<<(const volatile void* __p) {
+        return operator<<(const_cast<const void*>(__p));
+    }
+#endif
+
     basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb);
 
     _LIBCPP_INLINE_VISIBILITY