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

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Mar 4 15:16:55 PST 2024


Author: Louis Dionne
Date: 2024-03-04T18:16:52-05:00
New Revision: 4d80df0922ef7e48d53d4ae382977d8a2ff34ce0

URL: https://github.com/llvm/llvm-project/commit/4d80df0922ef7e48d53d4ae382977d8a2ff34ce0
DIFF: https://github.com/llvm/llvm-project/commit/4d80df0922ef7e48d53d4ae382977d8a2ff34ce0.diff

LOG: [libc++] Do not forward-declare syncstream outside experimental (#82511)

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.

Added: 
    

Modified: 
    libcxx/include/iosfwd
    libcxx/modules/std/iosfwd.inc

Removed: 
    


################################################################################
diff  --git a/libcxx/include/iosfwd b/libcxx/include/iosfwd
index 1579fa12754daf..f1c2cbd9669679 100644
--- a/libcxx/include/iosfwd
+++ b/libcxx/include/iosfwd
@@ -142,7 +142,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;
@@ -160,7 +160,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> >

diff  --git a/libcxx/modules/std/iosfwd.inc b/libcxx/modules/std/iosfwd.inc
index 410fb6aefed801..090d990d061e5e 100644
--- a/libcxx/modules/std/iosfwd.inc
+++ b/libcxx/modules/std/iosfwd.inc
@@ -18,19 +18,23 @@ 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
+#endif // _LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM
 
   using std::fpos;
 } // namespace std


        


More information about the libcxx-commits mailing list