From patchwork Wed Oct 7 16:55:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Rodgers X-Patchwork-Id: 1378144 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=appliantology.com Authentication-Results: ozlabs.org; dkim=pass (4096-bit key; secure) header.d=kolabnow.com header.i=@kolabnow.com header.a=rsa-sha256 header.s=dkim20160331 header.b=6PUg8grM; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C60pH0gN2z9sRk for ; Thu, 8 Oct 2020 03:55:50 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 449A2384400A; Wed, 7 Oct 2020 16:55:48 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx.kolabnow.com (mx.kolabnow.com [95.128.36.42]) by sourceware.org (Postfix) with ESMTPS id B2EB73846027; Wed, 7 Oct 2020 16:55:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B2EB73846027 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=appliantology.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=rodgert@appliantology.com Received: from localhost (unknown [127.0.0.1]) by ext-mx-out001.mykolab.com (Postfix) with ESMTP id 228241093; Wed, 7 Oct 2020 18:55:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kolabnow.com; h= content-transfer-encoding:mime-version:message-id:date:date :subject:subject:from:from:received:received:received; s= dkim20160331; t=1602089734; x=1603904135; bh=REgOZmliT2DiiyDJ8Ea cbZkz6PI2dcYKgUB8fzK2YCU=; b=6PUg8grM3Cey6lc21M0wJXlPyhQ+Dw81bxp jTj0DGb5BFRORiYwwp+ouWbfnHYseTeJzVANFFHRAOQqQHuCvCspS4vceoQcz7cR XckisEW2T0BtJTThiRPVMNziqYFRQDWQpuTuE7azEGa/ahgVpDbCB49Dfx3mBNOA Suk1zwt7vujLr539lP6TEx0S4wvmqBYj+fYGZ+Iz5E4zbmn6VlI8Cxay2Uu1Wl4u sHs7GqU8C/8TJWVXPC3ik3/ib4G6gpqZGCIkamTQYo7ztYYZEwZZtz6bPmJk6D69 Wo9ViQNG7/OIHeFWsOet6AIo8xRZAIaH7nl1poa7onyH0I8F/kExv29DY67V7ej6 e0+fe6uThb+rG35XKc7E+vI+Y/hofT1fSvgvlmOZLUX7GN8lmORm3Edjf9a1UdW2 +XbQeBBEkyXzzfXSUsULxsyjt5l1Bc3zDOdXQ9OdtofiJKGiHoNQf6HWNOobSrMT gyKiMFHy5I9L5s1p6qhbHDPPyGAMDNzYQptTkue0+6S9IIM1YqEHwFs/MbcUt5JM LmzWkjM7uY6I0d7yVFhLWeQXytWMLvIdvP7UD9Gf1WBQsz6xFx3Cah6cnivlsypV 6t7jKYjJp6tYolrYR9TMy44KC4d83O3tsq9gz7X+9YI+L2KluqHaN1FTK5AE1VbU LuSve+6g= X-Virus-Scanned: amavisd-new at mykolab.com X-Spam-Score: -1.9 X-Spam-Level: X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 Received: from mx.kolabnow.com ([127.0.0.1]) by localhost (ext-mx-out001.mykolab.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uaA3kSvanK5h; Wed, 7 Oct 2020 18:55:34 +0200 (CEST) Received: from int-mx002.mykolab.com (unknown [10.9.13.2]) by ext-mx-out001.mykolab.com (Postfix) with ESMTPS id 0B1E0B6C; Wed, 7 Oct 2020 18:55:33 +0200 (CEST) Received: from ext-subm002.mykolab.com (unknown [10.9.6.2]) by int-mx002.mykolab.com (Postfix) with ESMTPS id 9CC352342; Wed, 7 Oct 2020 18:55:33 +0200 (CEST) From: Thomas Rodgers To: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Subject: [PATCH] libstdc++: Implement C++20 features for Date: Wed, 7 Oct 2020 09:55:26 -0700 Message-Id: <20201007165526.2565948-1-rodgert@appliantology.com> MIME-Version: 1.0 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: trodgers@redhat.com Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" From: Thomas Rodgers New ctors and ::view() accessor for - * basic_stingbuf * basic_istringstream * basic_ostringstream * basic_stringstreamm New ::get_allocator() accessor for basic_stringbuf. libstdc++-v3/ChangeLog: * acinclude.m4 (glibcxx_SUBDIRS): Add src/c++20. * config/abi/pre/gnu.ver: Update GLIBCXX_3.4.29 for the addition of - basic_stringbuf::basic_stringbuf(allocator const&), basic_stringbuf::basic_stringbuf(openmode, allocator const&), basic_stringbuf::basic_stringbuf(basic_string&&, openmode), basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator const&), basic_stringbuf::get_allocator(), basic_stringbuf::view(), basic_istringstream::basic_istringstream(basic_string&&, openmode), basic_istringstream::basic_istringstream(openmode, allocator const&), basic_istringstream::view(), basic_ostringstream::basic_ostringstream(basic_string&&, openmode), basic_ostringstream::basic_ostringstream(openmode, allocator const&), basic_ostringstream::view(), basic_stringstream::basic_stringstream(basic_string&&, openmode), basic_stringstream::basic_stringstream(openmode, allocator const&), basic_stringstream::view(). * configure: Regenerate. * include/std/sstream: (basic_stringbuf::basic_stringbuf(allocator const&)): New constructor. (basic_stringbuf::basic_stringbuf(openmode, allocator const&)): Likewise. (basic_stringbuf::basic_stringbuf(basic_string&&, openmode)): Likewise. (basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator const&)): Likewise. (basic_stringbuf::get_allocator()): New method. (basic_stringbuf::view()): Likewise. (basic_istringstream::basic_istringstream(basic_string&&, openmode)): New constructor. (basic_istringstream::basic_istringstream(openmode, allocator const&)): Likewise (basic_istringstream::view()): New method. (basic_ostringstream::basic_ostringstream(basic_string&&, openmode)): New constructor. (basic_ostringstream::basic_ostringstream(openmode, allocator const&)): Likewise (basic_ostringstream::view()): New method. (basic_stringstream::basic_stringstream(basic_string&&, openmode)): New constructor. (basic_stringstream::basic_stringstream(openmode, allocator const&)): Likewise (basic_stringstream::view()): New method. * src/Makefile.in: Add c++20 directory. * src/Makefile.am: Regenerate. * src/c++20/Makefile.am: Add makefile for new sub-directory. * src/c++20/Makefile.in: Generate. * src/c++20/sstream-inst.cc: New file defining explicit instantiations for basic_stringbuf, basic_istringstream, basic_ostringstream, and basic_stringstream member functions added in C++20. * testsuite/27_io/basic_stringbuf/cons/char/2.cc: New test. * testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc: Likewise. * testsuite/27_io/basic_stringbuf/view/char/2.cc: Likewise. * testsuite/27_io/basic_stringbuf/view/wchar_t/2.cc: Likewise. * testsuite/27_io/basic_istringstream/cons/char/2.cc: Likewise. * testsuite/27_io/basic_istringstream/cons/wchar_t/2.cc: Likewise. * testsuite/27_io/basic_istringstream/view/char/2.cc: Likewise. * testsuite/27_io/basic_istringstream/view/wchar_t/2.cc: Likewise. * testsuite/27_io/basic_ostringstream/cons/char/2.cc: Likewise. * testsuite/27_io/basic_ostringstream/cons/wchar_t/2.cc: Likewise. * testsuite/27_io/basic_ostringstream/view/char/2.cc: Likewise. * testsuite/27_io/basic_ostringstream/view/wchar_t/2.cc: Likewise. * testsuite/27_io/basic_stringstream/cons/char/2.cc: Likewise. * testsuite/27_io/basic_stringstream/cons/wchar_t/2.cc: Likewise. * testsuite/27_io/basic_stringstream/view/char/2.cc: Likewise. * testsuite/27_io/basic_stringstream/view/wchar_t/2.cc: Likewise. --- .topdeps | 1 + .topmsg | 2 + libstdc++-v3/acinclude.m4 | 2 +- libstdc++-v3/config/abi/pre/gnu.ver | 60 ++ libstdc++-v3/configure | 16 +- libstdc++-v3/include/std/sstream | 198 +++++ libstdc++-v3/src/Makefile.am | 12 +- libstdc++-v3/src/Makefile.in | 14 +- libstdc++-v3/src/c++20/Makefile.am | 105 +++ libstdc++-v3/src/c++20/Makefile.in | 735 ++++++++++++++++++ libstdc++-v3/src/c++20/sstream-inst.cc | 110 +++ .../27_io/basic_istringstream/cons/char/1.cc | 84 ++ .../basic_istringstream/cons/wchar_t/1.cc | 84 ++ .../27_io/basic_istringstream/view/char/1.cc | 34 + .../basic_istringstream/view/wchar_t/1.cc | 35 + .../27_io/basic_ostringstream/cons/char/1.cc | 84 ++ .../basic_ostringstream/cons/wchar_t/1.cc | 84 ++ .../27_io/basic_ostringstream/view/char/1.cc | 34 + .../basic_ostringstream/view/wchar_t/1.cc | 35 + .../27_io/basic_stringbuf/cons/char/2.cc | 120 +++ .../27_io/basic_stringbuf/cons/wchar_t/2.cc | 105 +++ .../27_io/basic_stringbuf/view/char/1.cc | 34 + .../27_io/basic_stringbuf/view/wchar_t/1.cc | 35 + .../27_io/basic_stringstream/cons/char/1.cc | 84 ++ .../basic_stringstream/cons/wchar_t/1.cc | 84 ++ .../27_io/basic_stringstream/view/char/1.cc | 34 + .../basic_stringstream/view/wchar_t/1.cc | 35 + 27 files changed, 2248 insertions(+), 12 deletions(-) create mode 100644 .topdeps create mode 100644 .topmsg create mode 100644 libstdc++-v3/src/c++20/Makefile.am create mode 100644 libstdc++-v3/src/c++20/Makefile.in create mode 100644 libstdc++-v3/src/c++20/sstream-inst.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc diff --git a/.topdeps b/.topdeps new file mode 100644 index 00000000000..1f7391f92b6 --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +master diff --git a/.topmsg b/.topmsg new file mode 100644 index 00000000000..0c035ed2f0c --- /dev/null +++ b/.topmsg @@ -0,0 +1,2 @@ +From: Thomas Rodgers +Subject: [PATCH] t/trodgers/c2a_sstream diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index 133125ec4fa..b9452dd74cd 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -49,7 +49,7 @@ AC_DEFUN([GLIBCXX_CONFIGURE], [ # Keep these sync'd with the list in Makefile.am. The first provides an # expandable list at autoconf time; the second provides an expandable list # (i.e., shell variable) at configure time. - m4_define([glibcxx_SUBDIRS],[include libsupc++ src src/c++98 src/c++11 src/c++17 src/filesystem doc po testsuite python]) + m4_define([glibcxx_SUBDIRS],[include libsupc++ src src/c++98 src/c++11 src/c++17 src/c++20 src/filesystem doc po testsuite python]) SUBDIRS='glibcxx_SUBDIRS' # These need to be absolute paths, yet at the same time need to diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver index 87a48a21f53..3239bb1a53d 100644 --- a/libstdc++-v3/config/abi/pre/gnu.ver +++ b/libstdc++-v3/config/abi/pre/gnu.ver @@ -2322,6 +2322,66 @@ GLIBCXX_3.4.29 { # std::__atomic_futex_unsigned_base::_M_futex_wait_until_steady _ZNSt28__atomic_futex_unsigned_base26_M_futex_wait_until_steady*; + # basic_stringbuf::basic_stringbuf(allocator const&) + _ZNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEEC1ERKS3_; + _ZNSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEEC1ERKS3_; + + # basic_stringbuf::basic_stringbuf(ios_base::openmode, allocator const&) + _ZNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEEC1ESt13_Ios_OpenmodeRKS3; + _ZNSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEEC1ESt13_Ios_OpenmodeRKS3; + + # basic_stringbuf::basic_stringbuf(basic_string&&, ios_base::openmode) + _ZNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEEC1EONS_12basic_stringIcS2_S3_EESt13_Ios_Openmode; + _ZNSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEEC1EONS_12basic_stringIwS2_S3_EESt13_Ios_Openmode; + + # basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator const&) + _ZNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEEC1EOS4_RKS3_; + _ZNSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEEC1EOS4_RKS3_; + + # basic_stringbuf::get_allocator() + _ZNKSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEE13get_allocatorEv; + _ZNKSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEE13get_allocatorEv; + + # basic_stringbuf::view() + _ZNKSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEE4viewEv; + _ZNKSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEE4viewEv; + + # basic_istringstream::basic_istringstream(basic_string&&, ios_base::openmode) + _ZNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEC1EONS_12basic_stringIcS2_S3_EESt13_Ios_Openmode; + _ZNSt7__cxx1119basic_istringstreamIwSt11char_traitsIwESaIwEEC1EONS_12basic_stringIwS2_S3_EESt13_Ios_Openmode; + + # basic_istringstream::basic_istringstream(ios_base::openmode, allocator const&) + _ZNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEC1ESt13_Ios_OpenmodeRKS3_; + _ZNSt7__cxx1119basic_istringstreamIwSt11char_traitsIwESaIwEEC1ESt13_Ios_OpenmodeRKS3_; + + # basic_istringstream::view() + _ZNKSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEE4viewEv; + _ZNKSt7__cxx1119basic_istringstreamIwSt11char_traitsIwESaIwEE4viewEv; + + # basic_ostringstream::basic_ostringstream(basic_string&&, ios_base::openmode) + _ZNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEEC1EONS_12basic_stringIcS2_S3_EESt13_Ios_Openmode; + _ZNSt7__cxx1119basic_ostringstreamIwSt11char_traitsIwESaIwEEC1EONS_12basic_stringIwS2_S3_EESt13_Ios_Openmode; + + # basic_ostringstream::basic_ostringstream(ios_base::openmode, allocator const&) + _ZNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEEC1ESt13_Ios_OpenmodeRKS3_; + _ZNSt7__cxx1119basic_ostringstreamIwSt11char_traitsIwESaIwEEC1ESt13_Ios_OpenmodeRKS3_; + + # basic_ostringstream::view() + _ZNKSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEE4viewEv; + _ZNKSt7__cxx1119basic_ostringstreamIwSt11char_traitsIwESaIwEE4viewEv; + + # basic_stringstream::basic_stringstream(basic_string&&, ios_base::openmode) + _ZNSt7__cxx1119basic_stringstreamIcSt11char_traitsIcESaIcEEC1EONS_12basic_stringIcS2_S3_EESt13_Ios_Openmode; + _ZNSt7__cxx1119basic_stringstreamIwSt11char_traitsIwESaIwEEC1EONS_12basic_stringIwS2_S3_EESt13_Ios_Openmode; + + # basic_stringstream::basic_stringstream(ios_base::openmode, allocator const&) + _ZNSt7__cxx1119basic_stringstreamIcSt11char_traitsIcESaIcEEC1ESt13_Ios_OpenmodeRKS3_; + _ZNSt7__cxx1119basic_stringstreamIwSt11char_traitsIwESaIwEEC1ESt13_Ios_OpenmodeRKS3_; + + # basic_stringstream::view() + _ZNKSt7__cxx1119basic_stringstreamIcSt11char_traitsIcESaIcEE4viewEv; + _ZNKSt7__cxx1119basic_stringstreamIwSt11char_traitsIwESaIwEE4viewEv; + } GLIBCXX_3.4.28; # Symbols in the support library (libsupc++) have their own tag. diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index 7abf1b1ccc1..eecf63f4a59 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -5418,7 +5418,7 @@ $as_echo "$ac_cv_path_EGREP" >&6; } # expandable list at autoconf time; the second provides an expandable list # (i.e., shell variable) at configure time. - SUBDIRS='include libsupc++ src src/c++98 src/c++11 src/c++17 src/filesystem doc po testsuite python' + SUBDIRS='include libsupc++ src src/c++98 src/c++11 src/c++17 src/c++20 src/filesystem doc po testsuite python' # These need to be absolute paths, yet at the same time need to # canonicalize only relative paths, because then amd will not unmount @@ -78394,7 +78394,7 @@ ac_config_files="$ac_config_files doc/xsl/customization.xsl" # append it here. Only modify Makefiles that have just been created. # # Also, get rid of this simulated-VPATH thing that automake does. -ac_config_files="$ac_config_files include/Makefile libsupc++/Makefile src/Makefile src/c++98/Makefile src/c++11/Makefile src/c++17/Makefile src/filesystem/Makefile doc/Makefile po/Makefile testsuite/Makefile python/Makefile" +ac_config_files="$ac_config_files include/Makefile libsupc++/Makefile src/Makefile src/c++98/Makefile src/c++11/Makefile src/c++17/Makefile src/c++20/Makefile src/filesystem/Makefile doc/Makefile po/Makefile testsuite/Makefile python/Makefile" ac_config_commands="$ac_config_commands generate-headers" @@ -79650,6 +79650,7 @@ do "src/c++98/Makefile") CONFIG_FILES="$CONFIG_FILES src/c++98/Makefile" ;; "src/c++11/Makefile") CONFIG_FILES="$CONFIG_FILES src/c++11/Makefile" ;; "src/c++17/Makefile") CONFIG_FILES="$CONFIG_FILES src/c++17/Makefile" ;; + "src/c++20/Makefile") CONFIG_FILES="$CONFIG_FILES src/c++20/Makefile" ;; "src/filesystem/Makefile") CONFIG_FILES="$CONFIG_FILES src/filesystem/Makefile" ;; "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; "po/Makefile") CONFIG_FILES="$CONFIG_FILES po/Makefile" ;; @@ -81500,6 +81501,17 @@ _EOF ;; "src/c++17/Makefile":F) cat > vpsed$$ << \_EOF s!`test -f '$<' || echo '$(srcdir)/'`!! +_EOF + sed -f vpsed$$ $ac_file > tmp$$ + mv tmp$$ $ac_file + rm vpsed$$ + echo 'MULTISUBDIR =' >> $ac_file + ml_norecursion=yes + . ${multi_basedir}/config-ml.in + { ml_norecursion=; unset ml_norecursion;} + ;; + "src/c++20/Makefile":F) cat > vpsed$$ << \_EOF +s!`test -f '$<' || echo '$(srcdir)/'`!! _EOF sed -f vpsed$$ $ac_file > tmp$$ mv tmp$$ $ac_file diff --git a/libstdc++-v3/include/std/sstream b/libstdc++-v3/include/std/sstream index 9cca54d17d1..fb0fb9f8beb 100644 --- a/libstdc++-v3/include/std/sstream +++ b/libstdc++-v3/include/std/sstream @@ -165,6 +165,56 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 } #endif +#if __cplusplus > 201703L + basic_stringbuf(const allocator_type& __a) + : basic_stringbuf(ios_base::in | std::ios_base::out, __a) + { } + + basic_stringbuf(ios_base::openmode __mode, + const allocator_type& __a) + : __streambuf_type(), _M_mode(__mode), _M_string(__a) + { } + + explicit + basic_stringbuf(__string_type&& __s, + ios_base::openmode __mode = ios_base::in + | ios_base::out ) + : __streambuf_type(), _M_mode(__mode), _M_string(move(__s)) + { } + + template + basic_stringbuf(const basic_string<_CharT, _Traits, _SAlloc>& __s, + const allocator_type& __a ) + : basic_stringbuf(__s, ios_base::in | std::ios_base::out, __a ) + { } + + using __sv_type = basic_string_view; + + template + basic_stringbuf(const basic_string<_CharT, _Traits, _SAlloc>& __s, + ios_base::openmode __mode, + const allocator_type& __a) + : __streambuf_type(), _M_mode(__mode), + _M_string(static_cast<__sv_type>(__s), __a) + { } + + template + explicit + basic_stringbuf(const basic_string<_CharT, _Traits, _SAlloc>& __s, + ios_base::openmode __mode = ios_base::in + | ios_base::out) + : basic_stringbuf(__s, __mode, allocator_type{}) + { } + + basic_stringbuf(basic_stringbuf&& __rhs, const allocator_type& __a) + : basic_stringbuf(std::move(__rhs), __a, __xfer_bufptrs(__rhs, this)) + { __rhs._M_sync(const_cast(__rhs._M_string.data()), 0, 0); } + + allocator_type get_allocator() const noexcept + { return _M_string.get_allocator(); } + +#endif + // Get and set: /** * @brief Copying out the string buffer. @@ -207,6 +257,24 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 _M_stringbuf_init(_M_mode); } +#if __cplusplus > 201703L + __sv_type + view() const noexcept + { + if (this->pptr()) + { + // The current egptr() may not be the actual string end. + if (this->pptr() > this->egptr()) + return __sv_type(this->pbase(), this->pptr()); + else + return __sv_type(this->pbase(), this->egptr()); + } + else + return static_cast<__sv_type>(_M_string); + } + +#endif + protected: // Common initialization code goes here. void @@ -369,6 +437,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 : __streambuf_type(static_cast(__rhs)), _M_mode(__rhs._M_mode), _M_string(std::move(__rhs._M_string)) { } + +#if __cplusplus > 201703L + // The move constructor initializes an __xfer_bufptrs temporary then + // delegates to this constructor to performs moves during its lifetime. + basic_stringbuf(basic_stringbuf&& __rhs, const allocator_type& __a, + __xfer_bufptrs&&) + : __streambuf_type(static_cast(__rhs)), + _M_mode(__rhs._M_mode), _M_string(std::move(__rhs._M_string), __a) + { } +#endif #endif }; @@ -500,6 +578,40 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 } #endif +#if __cplusplus > 201703L + basic_istringstream(ios_base::openmode __mode, const allocator_type& __a) + : __istream_type(), _M_stringbuf(__mode | ios_base::in, __a) + { this->init(&_M_stringbuf); } + + explicit basic_istringstream(__string_type&& __str, + ios_base::openmode __mode = ios_base::in ) + : __istream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::in) + { this->init(&_M_stringbuf); } + + template + basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str, + const allocator_type& __a) + : basic_istringstream(__str, ios_base::in, __a) + { } + + using __sv_type = basic_string_view; + + template + basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str, + ios_base::openmode __mode, + const allocator_type& __a) + : __istream_type(), + _M_stringbuf(__string_type(__str.data(), __str.size()), + __mode | ios_base::in, __a) + { this->init(&_M_stringbuf); } + + template + explicit basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str, + ios_base::openmode __mode = ios_base::in) + : basic_istringstream(__str, __mode, allocator_type()) + { } +#endif + // Members: /** * @brief Accessing the underlying buffer. @@ -528,6 +640,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 void str(const __string_type& __s) { _M_stringbuf.str(__s); } + +#if __cplusplus > 201703L + __sv_type + view() const noexcept + { return _M_stringbuf.view(); } +#endif }; @@ -658,6 +776,40 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 } #endif +#if __cplusplus > 201703L + basic_ostringstream(ios_base::openmode __mode, const allocator_type& __a) + : __ostream_type(), _M_stringbuf(__mode | ios_base::out, __a) + { this->init(&_M_stringbuf); } + + explicit basic_ostringstream(__string_type&& __str, + ios_base::openmode __mode = ios_base::out ) + : __ostream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::out) + { this->init(&_M_stringbuf); } + + template + basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str, + const allocator_type& __a) + : basic_ostringstream(__str, ios_base::out, __a) + { } + + using __sv_type = basic_string_view; + + template + basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str, + ios_base::openmode __mode, + const allocator_type& __a) + : __ostream_type(), + _M_stringbuf(__string_type(__str.data(), __str.size()), + __mode | ios_base::out, __a) + { this->init(&_M_stringbuf); } + + template + explicit basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str, + ios_base::openmode __mode = ios_base::out) + : basic_ostringstream(__str, __mode, allocator_type()) + { } +#endif + // Members: /** * @brief Accessing the underlying buffer. @@ -686,6 +838,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 void str(const __string_type& __s) { _M_stringbuf.str(__s); } + +#if __cplusplus > 201703L + __sv_type + view() const noexcept + { return _M_stringbuf.view(); } +#endif }; @@ -812,6 +970,40 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 } #endif +#if __cplusplus > 201703L + basic_stringstream(ios_base::openmode __mode, const allocator_type& __a) + : __iostream_type(), _M_stringbuf(__mode, __a) + { this->init(&_M_stringbuf); } + + explicit basic_stringstream(__string_type&& __str, + ios_base::openmode __mode = ios_base::out + | ios_base::out) + : __iostream_type(), _M_stringbuf(std::move(__str), __mode) + { this->init(&_M_stringbuf); } + + template + basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str, + const allocator_type& __a) + : basic_stringstream(__str, ios_base::in | ios_base::out, __a) + { } + + using __sv_type = basic_string_view; + + template + basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str, + ios_base::openmode __mode, const allocator_type& __a) + : __iostream_type(), + _M_stringbuf(__string_type(__str.data(), __str.size()), __mode, __a) + { this->init(&_M_stringbuf); } + + template + explicit basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str, + ios_base::openmode __mode = ios_base::in + | ios_base::out) + : basic_stringstream(__str, __mode, allocator_type()) + { } +#endif + // Members: /** * @brief Accessing the underlying buffer. @@ -840,6 +1032,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 void str(const __string_type& __s) { _M_stringbuf.str(__s); } + +#if __cplusplus > 201703L + __sv_type + view() const noexcept + { return _M_stringbuf.view(); } +#endif }; #if __cplusplus >= 201103L diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am index a139adc81b3..9a6807ae8c6 100644 --- a/libstdc++-v3/src/Makefile.am +++ b/libstdc++-v3/src/Makefile.am @@ -29,7 +29,7 @@ filesystem_dir = endif ## Keep this list sync'd with acinclude.m4:GLIBCXX_CONFIGURE. -SUBDIRS = c++98 c++11 c++17 $(filesystem_dir) +SUBDIRS = c++98 c++11 c++17 c++20 $(filesystem_dir) # Cross compiler support. if VTV_CYGMIN @@ -60,6 +60,7 @@ endif vpath % $(top_srcdir)/src/c++98 vpath % $(top_srcdir)/src/c++11 vpath % $(top_srcdir)/src/c++17 +vpath % $(top_srcdir)/src/c++20 if ENABLE_FILESYSTEM_TS vpath % $(top_srcdir)/src/filesystem endif @@ -95,14 +96,16 @@ libstdc___la_LIBADD = \ $(top_builddir)/libsupc++/libsupc++convenience.la \ $(top_builddir)/src/c++98/libc++98convenience.la \ $(top_builddir)/src/c++11/libc++11convenience.la \ - $(top_builddir)/src/c++17/libc++17convenience.la + $(top_builddir)/src/c++17/libc++17convenience.la \ + $(top_builddir)/src/c++20/libc++20convenience.la libstdc___la_DEPENDENCIES = \ ${version_dep} \ $(top_builddir)/libsupc++/libsupc++convenience.la \ $(top_builddir)/src/c++98/libc++98convenience.la \ $(top_builddir)/src/c++11/libc++11convenience.la \ - $(top_builddir)/src/c++17/libc++17convenience.la + $(top_builddir)/src/c++17/libc++17convenience.la \ + $(top_builddir)/src/c++20/libc++20convenience.la libstdc___la_LDFLAGS = \ -version-info $(libtool_VERSION) ${version_arg} -lm @@ -153,7 +156,8 @@ compatibility-condvar.o: compatibility-condvar.cc # segregated in the sources with -D_GLIBCXX_SHARED. # # In the sub-directories of libsupc++, src/c++98, src/c++11, src/c++17, -# only -prefer-pic objects are generated for the convenience libraries. +# src/c++20, only -prefer-pic objects are generated for the convenience +# libraries. # # In the main src directory, make shared and static objects just for # the compat libraries. Shared objects are compiled with -prefer-pic diff --git a/libstdc++-v3/src/c++20/Makefile.am b/libstdc++-v3/src/c++20/Makefile.am new file mode 100644 index 00000000000..423a79f3686 --- /dev/null +++ b/libstdc++-v3/src/c++20/Makefile.am @@ -0,0 +1,105 @@ +## Makefile for the C++20 sources of the GNU C++ Standard library. +## +## Copyright (C) 1997-2020 Free Software Foundation, Inc. +## +## This file is part of the libstdc++ version 3 distribution. +## Process this file with automake to produce Makefile.in. + +## This file is part of the GNU ISO C++ Library. This library is free +## software; you can redistribute it and/or modify it under the +## terms of the GNU General Public License as published by the +## Free Software Foundation; either version 3, or (at your option) +## any later version. + +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. + +## You should have received a copy of the GNU General Public License along +## with this library; see the file COPYING3. If not see +## . + +include $(top_srcdir)/fragment.am + +# Convenience library for C++17 runtime. +noinst_LTLIBRARIES = libc++20convenience.la + +headers = + +if ENABLE_EXTERN_TEMPLATE +# XTEMPLATE_FLAGS = -fno-implicit-templates +inst_sources = \ + sstream-inst.cc +else +# XTEMPLATE_FLAGS = +inst_sources = +endif + +sources = + +vpath % $(top_srcdir)/src/c++20 + +libc__20convenience_la_SOURCES = $(sources) $(inst_sources) + +# AM_CXXFLAGS needs to be in each subdirectory so that it can be +# modified in a per-library or per-sub-library way. Need to manually +# set this option because CONFIG_CXXFLAGS has to be after +# OPTIMIZE_CXXFLAGS on the compile line so that -O2 can be overridden +# as the occasion calls for it. +AM_CXXFLAGS = \ + -std=gnu++20 \ + $(glibcxx_lt_pic_flag) $(glibcxx_compiler_shared_flag) \ + $(XTEMPLATE_FLAGS) $(VTV_CXXFLAGS) \ + $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS) \ + -fimplicit-templates + +AM_MAKEFLAGS = \ + "gxx_include_dir=$(gxx_include_dir)" + +# Libtool notes + +# 1) In general, libtool expects an argument such as `--tag=CXX' when +# using the C++ compiler, because that will enable the settings +# detected when C++ support was being configured. However, when no +# such flag is given in the command line, libtool attempts to figure +# it out by matching the compiler name in each configuration section +# against a prefix of the command line. The problem is that, if the +# compiler name and its initial flags stored in the libtool +# configuration file don't match those in the command line, libtool +# can't decide which configuration to use, and it gives up. The +# correct solution is to add `--tag CXX' to LTCXXCOMPILE and maybe +# CXXLINK, just after $(LIBTOOL), so that libtool doesn't have to +# attempt to infer which configuration to use. +# +# The second tag argument, `--tag disable-shared` means that libtool +# only compiles each source once, for static objects. In actuality, +# glibcxx_lt_pic_flag and glibcxx_compiler_shared_flag are added to +# the libtool command that is used create the object, which is +# suitable for shared libraries. The `--tag disable-shared` must be +# placed after --tag CXX lest things CXX undo the affect of +# disable-shared. + +# 2) Need to explicitly set LTCXXCOMPILE so that EXTRA_CXX_FLAGS is +# last. (That way, things like -O2 passed down from the toplevel can +# be overridden by --enable-debug.) +LTCXXCOMPILE = \ + $(LIBTOOL) --tag CXX --tag disable-shared \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CXX) $(TOPLEVEL_INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(EXTRA_CXX_FLAGS) + +LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS)) + +# 3) We'd have a problem when building the shared libstdc++ object if +# the rules automake generates would be used. We cannot allow g++ to +# be used since this would add -lstdc++ to the link line which of +# course is problematic at this point. So, we get the top-level +# directory to configure libstdc++-v3 to use gcc as the C++ +# compilation driver. +CXXLINK = \ + $(LIBTOOL) --tag CXX --tag disable-shared \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CXX) \ + $(VTV_CXXLINKFLAGS) \ + $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LTLDFLAGS) -o $@ diff --git a/libstdc++-v3/src/c++20/Makefile.in b/libstdc++-v3/src/c++20/Makefile.in new file mode 100644 index 00000000000..0e2de19ae59 diff --git a/libstdc++-v3/src/c++20/sstream-inst.cc b/libstdc++-v3/src/c++20/sstream-inst.cc new file mode 100644 index 00000000000..c7fa065bf18 --- /dev/null +++ b/libstdc++-v3/src/c++20/sstream-inst.cc @@ -0,0 +1,110 @@ +// Explicit instantiation file. + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// +// ISO C++ 14882: +// + +#ifndef _GLIBCXX_USE_CXX11_ABI +// Instantiations in this file use the new SSO std::string ABI unless included +// by another file which defines _GLIBCXX_USE_CXX11_ABI=0. +# define _GLIBCXX_USE_CXX11_ABI 1 +#endif +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +template basic_stringbuf::basic_stringbuf(const allocator_type&); +template basic_stringbuf::basic_stringbuf(ios_base::openmode, + const allocator_type&); +template basic_stringbuf::basic_stringbuf(__string_type&&, + ios_base::openmode); +template basic_stringbuf::basic_stringbuf(basic_stringbuf&&, + const allocator_type&); +template basic_stringbuf::allocator_type + basic_stringbuf::get_allocator() const noexcept; +template basic_stringbuf::__sv_type + basic_stringbuf::view() const noexcept; + + +template basic_istringstream::basic_istringstream(ios_base::openmode, + const allocator_type&); +template basic_istringstream::basic_istringstream(__string_type&&, + ios_base::openmode); +template basic_istringstream::__sv_type + basic_istringstream::view() const noexcept; + +template basic_ostringstream::basic_ostringstream(ios_base::openmode, + const allocator_type&); +template basic_ostringstream::basic_ostringstream(__string_type&&, + ios_base::openmode); +template basic_ostringstream::__sv_type + basic_ostringstream::view() const noexcept; + +template basic_stringstream::basic_stringstream(ios_base::openmode, + const allocator_type&); +template basic_stringstream::basic_stringstream(__string_type&&, + ios_base::openmode); +template basic_stringstream::__sv_type + basic_stringstream::view() const noexcept; + +#ifdef _GLIBCXX_USE_WCHAR_T +template basic_stringbuf::basic_stringbuf(const allocator_type&); +template basic_stringbuf::basic_stringbuf(ios_base::openmode, + const allocator_type&); +template basic_stringbuf::basic_stringbuf(__string_type&&, + ios_base::openmode); +template basic_stringbuf::basic_stringbuf(basic_stringbuf&&, + const allocator_type&); +template basic_stringbuf::allocator_type + basic_stringbuf::get_allocator() const noexcept; +template basic_stringbuf::__sv_type + basic_stringbuf::view() const noexcept; + +template basic_istringstream::basic_istringstream(ios_base::openmode, + const allocator_type&); +template basic_istringstream::basic_istringstream(__string_type&&, + ios_base::openmode); +template basic_istringstream::__sv_type + basic_istringstream::view() const noexcept; + +template basic_ostringstream::basic_ostringstream(ios_base::openmode, + const allocator_type&); +template basic_ostringstream::basic_ostringstream(__string_type&&, + ios_base::openmode); +template basic_ostringstream::__sv_type + basic_ostringstream::view() const noexcept; + +template basic_stringstream::basic_stringstream(ios_base::openmode, + const allocator_type&); +template basic_stringstream::basic_stringstream(__string_type&&, + ios_base::openmode); +template basic_stringstream::__sv_type + basic_stringstream::view() const noexcept; +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc new file mode 100644 index 00000000000..c902e55c4f7 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc @@ -0,0 +1,84 @@ +// Copyright (C) 2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons] + +// { dg-options "-std=gnu++2a" } +// { dg-do run { target c++2a } } + +#include +#include +#include +#include + +void +test01() +{ + std::istringstream::allocator_type a; + std::istringstream stm(std::ios_base::in, a); +} + +auto const cstr = "This is a test"; + +void +test02() +{ + std::string s1(cstr); + std::istringstream stm(std::move(s1)); + VERIFY( s1.empty() ); + + std::string s2(cstr); + VERIFY( stm.str() == s2 ); +} + +void +test03() +{ + using alloc_type = __gnu_test::tracker_allocator; + using str_type = std::basic_string, alloc_type>; + + auto const mode = std::ios_base::in; + str_type s1(cstr); + + { + std::istringstream::allocator_type a; + std::istringstream sbuf(s1, mode, a); + std::string s2(cstr); + VERIFY( sbuf.str() == s2 ); + } + + { + std::istringstream sbuf(s1, mode); + std::string s2(cstr); + VERIFY( sbuf.str() == s2 ); + } + + { + std::istringstream sbuf(s1); + std::string s2(cstr); + VERIFY( sbuf.str() == s2 ); + } +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc new file mode 100644 index 00000000000..db1e3ff1728 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc @@ -0,0 +1,84 @@ +// Copyright (C) 2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons] + +// { dg-options "-std=gnu++2a" } +// { dg-do run { target c++2a } } + +#include +#include +#include +#include + +void +test01() +{ + std::wistringstream::allocator_type a; + std::wistringstream stm(std::ios_base::in, a); +} + +auto const cstr = L"This is a test"; + +void +test02() +{ + std::wstring s1(cstr); + std::wistringstream stm(std::move(s1)); + VERIFY( s1.empty() ); + + std::wstring s2(cstr); + VERIFY( stm.str() == s2 ); +} + +void +test03() +{ + using alloc_type = __gnu_test::tracker_allocator; + using str_type = std::basic_string, alloc_type>; + + auto const mode = std::ios_base::in; + str_type s1(cstr); + + { + std::wistringstream::allocator_type a; + std::wistringstream sbuf(s1, mode, a); + std::wstring s2(cstr); + VERIFY( sbuf.str() == s2 ); + } + + { + std::wistringstream sbuf(s1, mode); + std::wstring s2(cstr); + VERIFY( sbuf.str() == s2 ); + } + + { + std::wistringstream sbuf(s1); + std::wstring s2(cstr); + VERIFY( sbuf.str() == s2 ); + } +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc new file mode 100644 index 00000000000..6859fec2ce9 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons] + +// { dg-options "-std=gnu++2a" } +// { dg-do run { target c++2a } } + +#include +#include +#include + +int +main() +{ + std::string s("This is a test"); + std::istringstream stm(s); + VERIFY( stm.view() == s ); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc new file mode 100644 index 00000000000..3c447bb23e9 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons] + +// { dg-options "-std=gnu++2a" } +// { dg-do run { target c++2a } } + +#include +#include +#include + +int +main() +{ + std::wstring s(L"This is a test"); + std::wistringstream stm(s); + VERIFY( stm.view() == s ); + return 0; +} + diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc new file mode 100644 index 00000000000..f7f71e0aa99 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc @@ -0,0 +1,84 @@ +// Copyright (C) 2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons] + +// { dg-options "-std=gnu++2a" } +// { dg-do run { target c++2a } } + +#include +#include +#include +#include + +void +test01() +{ + std::ostringstream::allocator_type a; + std::ostringstream stm(std::ios_base::in, a); +} + +auto const cstr = "This is a test"; + +void +test02() +{ + std::string s1(cstr); + std::ostringstream stm(std::move(s1)); + VERIFY( s1.empty() ); + + std::string s2(cstr); + VERIFY( stm.str() == s2 ); +} + +void +test03() +{ + using alloc_type = __gnu_test::tracker_allocator; + using str_type = std::basic_string, alloc_type>; + + auto const mode = std::ios_base::out; + str_type s1(cstr); + + { + std::ostringstream::allocator_type a; + std::ostringstream sbuf(s1, mode, a); + std::string s2(cstr); + VERIFY( sbuf.str() == s2 ); + } + + { + std::ostringstream sbuf(s1, mode); + std::string s2(cstr); + VERIFY( sbuf.str() == s2 ); + } + + { + std::ostringstream sbuf(s1); + std::string s2(cstr); + VERIFY( sbuf.str() == s2 ); + } +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc new file mode 100644 index 00000000000..10c28fe5880 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc @@ -0,0 +1,84 @@ +// Copyright (C) 2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons] + +// { dg-options "-std=gnu++2a" } +// { dg-do run { target c++2a } } + +#include +#include +#include +#include + +void +test01() +{ + std::wostringstream::allocator_type a; + std::wostringstream stm(std::ios_base::out, a); +} + +auto const cstr = L"This is a test"; + +void +test02() +{ + std::wstring s1(cstr); + std::wostringstream stm(std::move(s1)); + VERIFY( s1.empty() ); + + std::wstring s2(cstr); + VERIFY( stm.str() == s2 ); +} + +void +test03() +{ + using alloc_type = __gnu_test::tracker_allocator; + using str_type = std::basic_string, alloc_type>; + + auto const mode = std::ios_base::out; + str_type s1(cstr); + + { + std::wostringstream::allocator_type a; + std::wostringstream sbuf(s1, mode, a); + std::wstring s2(cstr); + VERIFY( sbuf.str() == s2 ); + } + + { + std::wostringstream sbuf(s1, mode); + std::wstring s2(cstr); + VERIFY( sbuf.str() == s2 ); + } + + { + std::wostringstream sbuf(s1); + std::wstring s2(cstr); + VERIFY( sbuf.str() == s2 ); + } +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc new file mode 100644 index 00000000000..d080e3c7771 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons] + +// { dg-options "-std=gnu++2a" } +// { dg-do run { target c++2a } } + +#include +#include +#include + +int +main() +{ + std::string s("This is a test"); + std::ostringstream stm(s); + VERIFY( stm.view() == s ); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc new file mode 100644 index 00000000000..8cb51a30e24 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons] + +// { dg-options "-std=gnu++2a" } +// { dg-do run { target c++2a } } + +#include +#include +#include + +int +main() +{ + std::wstring s(L"This is a test"); + std::wostringstream stm(s); + VERIFY( stm.view() == s ); + return 0; +} + diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc new file mode 100644 index 00000000000..e611a2fcfce --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc @@ -0,0 +1,120 @@ +// Copyright (C) 2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons] + +// { dg-options "-std=gnu++2a" } +// { dg-do run { target c++2a } } + +#include +#include +#include +#include + +void +test01() +{ + { + using alloc_type = __gnu_test::uneq_allocator; + using sbuf_t = std::basic_stringbuf, + alloc_type>; + + alloc_type aa; + sbuf_t sbuf1(aa); + VERIFY( aa == sbuf1.get_allocator() ); + + alloc_type aaa(42); + sbuf_t sbuf2(aaa); + VERIFY( aaa == sbuf2.get_allocator() ); + + VERIFY( sbuf1.get_allocator() != sbuf2.get_allocator() ); + } + + std::stringbuf::allocator_type a; + { + std::stringbuf sbuf(std::ios_base::in, a); + } + + { + std::stringbuf sbuf(a); + } +} + +auto const cstr = "This is a test"; + +void +test02() +{ + std::string s1(cstr); + std::stringbuf sbuf(std::move(s1)); + VERIFY( s1.empty() ); + + std::string s2(cstr); + VERIFY( sbuf.str() == s2 ); +} + +void +test03() +{ + using alloc_type = __gnu_test::tracker_allocator; + using str_type = std::basic_string, alloc_type>; + + auto const mode = std::ios_base::in | std::ios_base::out; + str_type s1(cstr); + + { + std::stringbuf::allocator_type a; + std::stringbuf sbuf(s1, mode, a); + std::string s2(cstr); + VERIFY( sbuf.str() == s2 ); + } + + { + std::stringbuf sbuf(s1, mode); + std::string s2(cstr); + VERIFY( sbuf.str() == s2 ); + } + + { + std::stringbuf sbuf(s1); + std::string s2(cstr); + VERIFY( sbuf.str() == s2 ); + } +} + +void +test04() +{ + std::stringbuf sbuf1(cstr); + + std::stringbuf::allocator_type a; + std::stringbuf sbuf2(std::move(sbuf1), a); + VERIFY( sbuf1.str().empty() ); + + std::string s(cstr); + VERIFY( sbuf2.str() == s ); +} + +int +main() +{ + test01(); + test02(); + test03(); + test04(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc new file mode 100644 index 00000000000..d2c435b2f10 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc @@ -0,0 +1,105 @@ +// Copyright (C) 2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons] + +// { dg-options "-std=gnu++2a" } +// { dg-do run { target c++2a } } + +#include +#include +#include +#include + +void +test01() +{ + std::wstringbuf::allocator_type a; + { + std::wstringbuf sbuf(std::ios_base::in, a); + } + + { + std::wstringbuf sbuf(a); + } +} + +auto const cstr = L"This is a test"; + +void +test02() +{ + std::wstring s1(cstr); + std::wstringbuf sbuf(std::move(s1)); + VERIFY( s1.empty() ); + + std::wstring s2(cstr); + VERIFY( sbuf.str() == s2 ); +} + +void +test03() +{ + using alloc_type = __gnu_test::tracker_allocator; + using str_type = std::basic_string, alloc_type>; + + auto const mode = std::ios_base::in | std::ios_base::out; + str_type s1(cstr); + + { + std::wstringbuf::allocator_type a; + std::wstringbuf sbuf(s1, mode, a); + std::wstring s2(cstr); + VERIFY( sbuf.str() == s2 ); + } + + { + std::wstringbuf sbuf(s1, mode); + std::wstring s2(cstr); + VERIFY( sbuf.str() == s2 ); + } + + { + std::wstringbuf sbuf(s1); + std::wstring s2(cstr); + VERIFY( sbuf.str() == s2 ); + } +} + +void +test04() +{ + std::wstringbuf sbuf1(cstr); + + std::wstringbuf::allocator_type a; + std::wstringbuf sbuf2(std::move(sbuf1), a); + VERIFY( sbuf1.str().empty() ); + + std::wstring s(cstr); + VERIFY( sbuf2.str() == s ); +} + +int +main() +{ + test01(); + test02(); + test03(); + test04(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc new file mode 100644 index 00000000000..40af4b094cb --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons] + +// { dg-options "-std=gnu++2a" } +// { dg-do run { target c++2a } } + +#include +#include +#include + +int +main() +{ + std::string s("This is a test"); + std::stringbuf sbuf(s); + VERIFY( sbuf.view() == s ); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc new file mode 100644 index 00000000000..ffa27996803 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons] + +// { dg-options "-std=gnu++2a" } +// { dg-do run { target c++2a } } + +#include +#include +#include + +int +main() +{ + std::wstring s(L"This is a test"); + std::wstringbuf sbuf(s); + VERIFY( sbuf.view() == s ); + return 0; +} + diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc new file mode 100644 index 00000000000..021341342be --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc @@ -0,0 +1,84 @@ +// Copyright (C) 2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons] + +// { dg-options "-std=gnu++2a" } +// { dg-do run { target c++2a } } + +#include +#include +#include +#include + +void +test01() +{ + std::stringstream::allocator_type a; + std::stringstream stm(std::ios_base::in, a); +} + +auto const cstr = "This is a test"; + +void +test02() +{ + std::string s1(cstr); + std::stringstream stm(std::move(s1)); + VERIFY( s1.empty() ); + + std::string s2(cstr); + VERIFY( stm.str() == s2 ); +} + +void +test03() +{ + using alloc_type = __gnu_test::tracker_allocator; + using str_type = std::basic_string, alloc_type>; + + auto const mode = std::ios_base::in | std::ios_base::out; + str_type s1(cstr); + + { + std::stringstream::allocator_type a; + std::stringstream sbuf(s1, mode, a); + std::string s2(cstr); + VERIFY( sbuf.str() == s2 ); + } + + { + std::stringstream sbuf(s1, mode); + std::string s2(cstr); + VERIFY( sbuf.str() == s2 ); + } + + { + std::stringstream sbuf(s1); + std::string s2(cstr); + VERIFY( sbuf.str() == s2 ); + } +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc new file mode 100644 index 00000000000..db1e3ff1728 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc @@ -0,0 +1,84 @@ +// Copyright (C) 2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons] + +// { dg-options "-std=gnu++2a" } +// { dg-do run { target c++2a } } + +#include +#include +#include +#include + +void +test01() +{ + std::wistringstream::allocator_type a; + std::wistringstream stm(std::ios_base::in, a); +} + +auto const cstr = L"This is a test"; + +void +test02() +{ + std::wstring s1(cstr); + std::wistringstream stm(std::move(s1)); + VERIFY( s1.empty() ); + + std::wstring s2(cstr); + VERIFY( stm.str() == s2 ); +} + +void +test03() +{ + using alloc_type = __gnu_test::tracker_allocator; + using str_type = std::basic_string, alloc_type>; + + auto const mode = std::ios_base::in; + str_type s1(cstr); + + { + std::wistringstream::allocator_type a; + std::wistringstream sbuf(s1, mode, a); + std::wstring s2(cstr); + VERIFY( sbuf.str() == s2 ); + } + + { + std::wistringstream sbuf(s1, mode); + std::wstring s2(cstr); + VERIFY( sbuf.str() == s2 ); + } + + { + std::wistringstream sbuf(s1); + std::wstring s2(cstr); + VERIFY( sbuf.str() == s2 ); + } +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc new file mode 100644 index 00000000000..c596b5872ed --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons] + +// { dg-options "-std=gnu++2a" } +// { dg-do run { target c++2a } } + +#include +#include +#include + +int +main() +{ + std::string s("This is a test"); + std::stringstream stm(s); + VERIFY( stm.view() == s ); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc new file mode 100644 index 00000000000..a5f251969c3 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.7.1.1 basic_stringbuf constructors [lib.stringbuf.cons] + +// { dg-options "-std=gnu++2a" } +// { dg-do run { target c++2a } } + +#include +#include +#include + +int +main() +{ + std::wstring s(L"This is a test"); + std::wstringstream stm(s); + VERIFY( stm.view() == s ); + return 0; +} +