[libcxx-commits] [libcxx] [libc++] Do not forward-declare syncstream outside experimental (PR #82511)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Feb 27 14:34:32 PST 2024


https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/82511

>From eb443dc150b439587d46fa904cabad63733cec90 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Wed, 21 Feb 2024 09:27:09 -0800
Subject: [PATCH 1/2] [libc++] Do not forward-declare syncstream outside
 experimental

We only define the classes in <syncstream> when experimental
library features are enabled, but we would forward-declare
them in <iosfwd> even when they are disabled. This led to
confusing error messages about being unable to instantiate
an undefined template.
---
 libcxx/include/iosfwd | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libcxx/include/iosfwd b/libcxx/include/iosfwd
index e28998d004156d..728700853fb331 100644
--- a/libcxx/include/iosfwd
+++ b/libcxx/include/iosfwd
@@ -143,7 +143,7 @@ typedef fpos<mbstate_t> u8streampos;
 typedef fpos<mbstate_t> u16streampos;
 typedef fpos<mbstate_t> u32streampos;
 
-#if _LIBCPP_STD_VER >= 20
+#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM)
 
 template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT>>
 class basic_syncbuf;
@@ -161,7 +161,7 @@ using osyncstream = basic_osyncstream<char>;
 using wosyncstream = basic_osyncstream<wchar_t>;
 #  endif
 
-#endif // _LIBCPP_STD_VER >=20
+#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM)
 
 // Include other forward declarations here
 template <class _Tp, class _Alloc = allocator<_Tp> >

>From 59c8aef2b241453c4b0220133c06d1c34591f5ac Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 27 Feb 2024 17:34:21 -0500
Subject: [PATCH 2/2] Fix iosfwd module in non-experimental mode

---
 libcxx/modules/std/iosfwd.inc | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libcxx/modules/std/iosfwd.inc b/libcxx/modules/std/iosfwd.inc
index 410fb6aefed801..44759efd150897 100644
--- a/libcxx/modules/std/iosfwd.inc
+++ b/libcxx/modules/std/iosfwd.inc
@@ -18,18 +18,22 @@ export namespace std {
   using std::u8streampos;
 #endif
 
+#ifndef _LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM
   using std::basic_osyncstream;
   using std::basic_syncbuf;
+#endif
 
   using std::istreambuf_iterator;
   using std::ostreambuf_iterator;
 
+#ifndef _LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM
   using std::osyncstream;
   using std::syncbuf;
 
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
   using std::wosyncstream;
   using std::wsyncbuf;
+# endif
 #endif
 
   using std::fpos;



More information about the libcxx-commits mailing list