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

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Feb 21 09:29:24 PST 2024


https://github.com/ldionne created https://github.com/llvm/llvm-project/pull/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.

>From 39ec2d5cd2aa77b59e2a67adea0c06e11ff5ae2d 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] [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> >



More information about the libcxx-commits mailing list