From patchwork Fri Aug 26 20:16:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 795 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:ecc5:0:0:0:0:0 with SMTP id s5csp390276wro; Fri, 26 Aug 2022 13:18:01 -0700 (PDT) X-Google-Smtp-Source: AA6agR6p8hLRun0SGPzuM3ylt7+o1YHYZuTx5mKLA/DdF4T9ekVAqPEQUvIoP0HWayif0pNVEWjv X-Received: by 2002:a05:6402:1041:b0:446:b290:ea94 with SMTP id e1-20020a056402104100b00446b290ea94mr7885536edu.389.1661545081322; Fri, 26 Aug 2022 13:18:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661545081; cv=none; d=google.com; s=arc-20160816; b=XSgZZ0TOwRURas1JPw5c66CNDl1E5Pw6RVw+ZDpD8eSghrTio7dPNLMFG3DTcxOa4e Wcc/PH1O5cwUfD3dlaxITAd5H9T80P1yWSjxsL+y39+9162SbKX3fKMhzs10GO4xRO6m 9ZEHVx0YYx9aQDQbdjW7BFWNq1tw5oXpHEvtomshPLD53FEURqwTYacyuTHmy/QCxTxz /BiYdMlN6HF0zyoYMliWC0na6QdH+84MzxposHuhmcVQXQPgSRk4b+EvBv7r5yD5gejj Fln5IFnexnKBq0Kg+NangDippEF6UV4PRgsPgiI/V+EXtBbR1OPHw9ikaHrydZDtok/Z NLMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=cA0SqEG6rXnKkvAHkUZfEiH/NeZqS+2S9L7IJUrCeE0=; b=CbyXOwV9e8db9W0ppwwPqMZRJy21i62aidpvNoJ+3GtVJ+M34YFNV4hFNZTjrRQZZ1 coiJ/7CT9ekmEEYNcKcefVm0uIYz5hATJ9Im6fLZ5Zl4dfCuW6GQ3WzVwKoEbAotmnwB IvsBm8LWZLo/tPRM8mH6CcvT3PcytEHBZWkWz0OnWV31fUp9ht7GlGAFFmOnOqCosJy9 GxC39AKaHAatuKc6fFtLUWy2oLXc6tZ8IIIPa1E1tQrcV/UPtUqA9Sd/nVQa6Z4V60zY XgqDkw2HtNo+imQNPQaoXuFabbwu9TmaVj615Yz7wKlT8NvKe+VLcvjSNT7o0JzIJnpx S+xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=nfULNw2c; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id hq25-20020a1709073f1900b00730a4ef4036si2336887ejc.50.2022.08.26.13.18.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 13:18:01 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=nfULNw2c; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 60289384D197 for ; Fri, 26 Aug 2022 20:17:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 60289384D197 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1661545066; bh=cA0SqEG6rXnKkvAHkUZfEiH/NeZqS+2S9L7IJUrCeE0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=nfULNw2cIXV6fmnjAhXDk2jT5GNlSmQ6JS/Xc6J2jHmgq0eq7utN0Xvzjm2J7cPKi Ng90PcRpNDMiKNFAes97/Gc4KZMMSJg8M40ciif0N14c4o1awr1pahzYNYyJRdKZEh JJrdoo1Zh+FyBNAjeC1HHT7iDkZAW7AAOONl8EMs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 469443850234 for ; Fri, 26 Aug 2022 20:16:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 469443850234 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-619-l4EdiufpPoiDymnaCpqDEQ-1; Fri, 26 Aug 2022 16:16:40 -0400 X-MC-Unique: l4EdiufpPoiDymnaCpqDEQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E82551C06903; Fri, 26 Aug 2022 20:16:39 +0000 (UTC) Received: from localhost (unknown [10.33.36.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46293C15BBA; Fri, 26 Aug 2022 20:16:39 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] libstdc++: Add [[nodiscard]] attribute to and Date: Fri, 26 Aug 2022 21:16:38 +0100 Message-Id: <20220826201638.214427-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1742256295193857907?= X-GMAIL-MSGID: =?utf-8?q?1742256295193857907?= I plan to commit this after testing finishes, probably on Monday. Basic testing on powerpc64le-linux is clean, but I'm still running debug mode and other variations of tests. -- >8 -- libstdc++-v3/ChangeLog: * include/bits/basic_string.h (basic_string): Add nodiscard attribute to all relevant functions. * include/std/string_view (basic_string_view): Likewise. * testsuite/21_strings/basic_string/capacity/1.cc: Cast unused results to void. * testsuite/21_strings/basic_string/capacity/char/1.cc: Likewise. * testsuite/21_strings/basic_string/capacity/wchar_t/1.cc: Likewise. * testsuite/21_strings/basic_string/cons/char/self_move.cc: Likewise. * testsuite/21_strings/basic_string/element_access/char/1.cc: Likewise. * testsuite/21_strings/basic_string/element_access/char/21674.cc: Likewise. * testsuite/21_strings/basic_string/element_access/wchar_t/1.cc: Likewise. * testsuite/21_strings/basic_string/element_access/wchar_t/21674.cc: Likewise. * testsuite/21_strings/basic_string/lwg2758.cc: Likewise. * testsuite/21_strings/basic_string/lwg2946.cc: Likewise. * testsuite/21_strings/basic_string/operations/contains/nonnull.cc: Add -Wno-unused-result to options. * testsuite/21_strings/basic_string/operations/ends_with/nonnull.cc: Likewise. * testsuite/21_strings/basic_string/operations/starts_with/nonnull.cc: Likewise. * testsuite/21_strings/basic_string/operators/char/1.cc: Cast unused results to void. * testsuite/21_strings/basic_string/operators/wchar_t/1.cc: Likewise. * testsuite/21_strings/basic_string_view/capacity/1.cc: Likewise. * testsuite/21_strings/basic_string_view/element_access/char/1.cc: Likewise. * testsuite/21_strings/basic_string_view/element_access/char/2.cc: Likewise. * testsuite/21_strings/basic_string_view/element_access/wchar_t/1.cc: Likewise. * testsuite/21_strings/basic_string_view/element_access/wchar_t/2.cc: Likewise. * testsuite/21_strings/basic_string_view/operations/contains/nonnull.cc: Likewise. Add -Wno-unused-result to options. * testsuite/21_strings/basic_string_view/operations/ends_with/nonnull.cc: Likewise. * testsuite/21_strings/basic_string_view/operations/starts_with/nonnull.cc: Likewise. * testsuite/27_io/basic_stringbuf/sputbackc/char/1.cc: Cast unused results to void. * testsuite/27_io/basic_stringbuf/sputbackc/wchar_t/1.cc: Likewise. * testsuite/27_io/basic_stringbuf/sungetc/char/1.cc: Likewise. * testsuite/27_io/basic_stringbuf/sungetc/wchar_t/1.cc: Likewise. --- libstdc++-v3/include/bits/basic_string.h | 211 +++++++++++------- libstdc++-v3/include/std/string_view | 107 +++++++-- .../21_strings/basic_string/capacity/1.cc | 2 +- .../basic_string/capacity/char/1.cc | 6 +- .../basic_string/capacity/wchar_t/1.cc | 6 +- .../basic_string/cons/char/self_move.cc | 2 +- .../basic_string/element_access/char/1.cc | 4 +- .../basic_string/element_access/char/21674.cc | 2 +- .../basic_string/element_access/wchar_t/1.cc | 4 +- .../element_access/wchar_t/21674.cc | 2 +- .../21_strings/basic_string/lwg2758.cc | 4 +- .../21_strings/basic_string/lwg2946.cc | 16 +- .../operations/contains/nonnull.cc | 2 +- .../operations/ends_with/nonnull.cc | 2 +- .../operations/starts_with/nonnull.cc | 2 +- .../basic_string/operators/char/1.cc | 4 +- .../basic_string/operators/wchar_t/1.cc | 4 +- .../basic_string_view/capacity/1.cc | 2 +- .../element_access/char/1.cc | 2 +- .../element_access/char/2.cc | 2 +- .../element_access/wchar_t/1.cc | 2 +- .../element_access/wchar_t/2.cc | 2 +- .../operations/contains/nonnull.cc | 2 +- .../operations/ends_with/nonnull.cc | 2 +- .../operations/starts_with/nonnull.cc | 2 +- .../27_io/basic_stringbuf/sputbackc/char/1.cc | 10 +- .../basic_stringbuf/sputbackc/wchar_t/1.cc | 10 +- .../27_io/basic_stringbuf/sungetc/char/1.cc | 10 +- .../basic_stringbuf/sungetc/wchar_t/1.cc | 10 +- 29 files changed, 279 insertions(+), 157 deletions(-) diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index 9d8b415302b..0df64ea98ca 100644 --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -942,7 +942,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * Returns a read/write iterator that points to the first character in * the %string. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR iterator begin() _GLIBCXX_NOEXCEPT { return iterator(_M_data()); } @@ -951,7 +951,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * Returns a read-only (constant) iterator that points to the first * character in the %string. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR const_iterator begin() const _GLIBCXX_NOEXCEPT { return const_iterator(_M_data()); } @@ -960,7 +960,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * Returns a read/write iterator that points one past the last * character in the %string. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR iterator end() _GLIBCXX_NOEXCEPT { return iterator(_M_data() + this->size()); } @@ -969,7 +969,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * Returns a read-only (constant) iterator that points one past the * last character in the %string. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR const_iterator end() const _GLIBCXX_NOEXCEPT { return const_iterator(_M_data() + this->size()); } @@ -979,7 +979,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * character in the %string. Iteration is done in reverse element * order. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR reverse_iterator rbegin() _GLIBCXX_NOEXCEPT { return reverse_iterator(this->end()); } @@ -989,7 +989,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * to the last character in the %string. Iteration is done in * reverse element order. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR const_reverse_iterator rbegin() const _GLIBCXX_NOEXCEPT { return const_reverse_iterator(this->end()); } @@ -999,7 +999,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * first character in the %string. Iteration is done in reverse * element order. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR reverse_iterator rend() _GLIBCXX_NOEXCEPT { return reverse_iterator(this->begin()); } @@ -1009,7 +1009,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * to one before the first character in the %string. Iteration * is done in reverse element order. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR const_reverse_iterator rend() const _GLIBCXX_NOEXCEPT { return const_reverse_iterator(this->begin()); } @@ -1019,7 +1019,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * Returns a read-only (constant) iterator that points to the first * character in the %string. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR const_iterator cbegin() const noexcept { return const_iterator(this->_M_data()); } @@ -1028,7 +1028,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * Returns a read-only (constant) iterator that points one past the * last character in the %string. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR const_iterator cend() const noexcept { return const_iterator(this->_M_data() + this->size()); } @@ -1038,7 +1038,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * to the last character in the %string. Iteration is done in * reverse element order. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(this->end()); } @@ -1048,7 +1048,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * to one before the first character in the %string. Iteration * is done in reverse element order. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR const_reverse_iterator crend() const noexcept { return const_reverse_iterator(this->begin()); } @@ -1058,20 +1058,20 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 // Capacity: /// Returns the number of characters in the string, not including any /// null-termination. - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR size_type size() const _GLIBCXX_NOEXCEPT { return _M_string_length; } /// Returns the number of characters in the string, not including any /// null-termination. - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR size_type length() const _GLIBCXX_NOEXCEPT { return _M_string_length; } /// Returns the size() of the largest possible %string. - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR size_type max_size() const _GLIBCXX_NOEXCEPT { return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; } @@ -1127,7 +1127,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * Returns the total number of characters that the %string can hold * before needing to allocate more memory. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR size_type capacity() const _GLIBCXX_NOEXCEPT { @@ -1194,7 +1194,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * out_of_range lookups are not defined. (For checked lookups * see at().) */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR const_reference operator[] (size_type __pos) const _GLIBCXX_NOEXCEPT { @@ -1212,7 +1212,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * out_of_range lookups are not defined. (For checked lookups * see at().) */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR reference operator[](size_type __pos) { @@ -1234,7 +1234,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * first checked that it is in the range of the string. The function * throws out_of_range if the check fails. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR const_reference at(size_type __n) const { @@ -1256,7 +1256,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * first checked that it is in the range of the string. The function * throws out_of_range if the check fails. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR reference at(size_type __n) { @@ -1273,7 +1273,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * Returns a read/write reference to the data at the first * element of the %string. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR reference front() noexcept { @@ -1285,7 +1285,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * Returns a read-only (constant) reference to the data at the first * element of the %string. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR const_reference front() const noexcept { @@ -1297,7 +1297,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * Returns a read/write reference to the data at the last * element of the %string. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR reference back() noexcept { @@ -1309,7 +1309,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * Returns a read-only (constant) reference to the data at the * last element of the %string. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR const_reference back() const noexcept { @@ -2549,7 +2549,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * This is a handle to internal data. Do not modify or dire things may * happen. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR const _CharT* c_str() const _GLIBCXX_NOEXCEPT { return _M_data(); } @@ -2562,7 +2562,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * allows modifying the contents use @c &str[0] instead, * (or in C++17 the non-const @c str.data() overload). */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR const _CharT* data() const _GLIBCXX_NOEXCEPT { return _M_data(); } @@ -2574,7 +2574,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * This is a pointer to the character sequence held by the string. * Modifying the characters in the sequence is allowed. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR _CharT* data() noexcept { return _M_data(); } @@ -2583,7 +2583,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 /** * @brief Return copy of allocator used to construct this string. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR allocator_type get_allocator() const _GLIBCXX_NOEXCEPT { return _M_get_allocator(); } @@ -2600,7 +2600,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * returns the index where it begins. If not found, returns * npos. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR size_type find(const _CharT* __s, size_type __pos, size_type __n) const _GLIBCXX_NOEXCEPT; @@ -2615,7 +2615,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * this string. If found, returns the index where it begins. If not * found, returns npos. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR size_type find(const basic_string& __str, size_type __pos = 0) const _GLIBCXX_NOEXCEPT @@ -2629,7 +2629,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * @return Index of start of first occurrence. */ template - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR _If_sv<_Tp, size_type> find(const _Tp& __svt, size_type __pos = 0) const noexcept(is_same<_Tp, __sv_type>::value) @@ -2649,7 +2649,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * __s within this string. If found, returns the index where * it begins. If not found, returns npos. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR size_type find(const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT { @@ -2667,7 +2667,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * this string. If found, returns the index where it was * found. If not found, returns npos. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR size_type find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT; @@ -2681,7 +2681,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * __str within this string. If found, returns the index where * it begins. If not found, returns npos. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR size_type rfind(const basic_string& __str, size_type __pos = npos) const _GLIBCXX_NOEXCEPT @@ -2695,7 +2695,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * @return Index of start of last occurrence. */ template - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR _If_sv<_Tp, size_type> rfind(const _Tp& __svt, size_type __pos = npos) const noexcept(is_same<_Tp, __sv_type>::value) @@ -2717,7 +2717,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * returns the index where it begins. If not found, returns * npos. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const _GLIBCXX_NOEXCEPT; @@ -2732,7 +2732,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * @a __s within this string. If found, returns the index * where it begins. If not found, returns npos. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR size_type rfind(const _CharT* __s, size_type __pos = npos) const { @@ -2750,7 +2750,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * this string. If found, returns the index where it was * found. If not found, returns npos. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR size_type rfind(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT; @@ -2765,7 +2765,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * returns the index where it was found. If not found, returns * npos. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR size_type find_first_of(const basic_string& __str, size_type __pos = 0) const _GLIBCXX_NOEXCEPT @@ -2780,7 +2780,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * @return Index of first occurrence. */ template - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR _If_sv<_Tp, size_type> find_first_of(const _Tp& __svt, size_type __pos = 0) const noexcept(is_same<_Tp, __sv_type>::value) @@ -2802,7 +2802,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * found, returns the index where it was found. If not found, * returns npos. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const _GLIBCXX_NOEXCEPT; @@ -2817,7 +2817,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * characters of @a __s within this string. If found, returns * the index where it was found. If not found, returns npos. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR size_type find_first_of(const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT @@ -2838,7 +2838,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * * Note: equivalent to find(__c, __pos). */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR size_type find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT { return this->find(__c, __pos); } @@ -2854,7 +2854,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * returns the index where it was found. If not found, returns * npos. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR size_type find_last_of(const basic_string& __str, size_type __pos = npos) const _GLIBCXX_NOEXCEPT @@ -2869,7 +2869,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * @return Index of last occurrence. */ template - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR _If_sv<_Tp, size_type> find_last_of(const _Tp& __svt, size_type __pos = npos) const noexcept(is_same<_Tp, __sv_type>::value) @@ -2891,7 +2891,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * found, returns the index where it was found. If not found, * returns npos. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const _GLIBCXX_NOEXCEPT; @@ -2906,7 +2906,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * characters of @a __s within this string. If found, returns * the index where it was found. If not found, returns npos. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR size_type find_last_of(const _CharT* __s, size_type __pos = npos) const _GLIBCXX_NOEXCEPT @@ -2927,7 +2927,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * * Note: equivalent to rfind(__c, __pos). */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR size_type find_last_of(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT { return this->rfind(__c, __pos); } @@ -2942,7 +2942,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * in @a __str within this string. If found, returns the index where it * was found. If not found, returns npos. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR size_type find_first_not_of(const basic_string& __str, size_type __pos = 0) const _GLIBCXX_NOEXCEPT @@ -2957,8 +2957,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * @return Index of first occurrence. */ template + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR _If_sv<_Tp, size_type> - _GLIBCXX20_CONSTEXPR find_first_not_of(const _Tp& __svt, size_type __pos = 0) const noexcept(is_same<_Tp, __sv_type>::value) { @@ -2979,7 +2979,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * this string. If found, returns the index where it was * found. If not found, returns npos. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const _GLIBCXX_NOEXCEPT; @@ -2994,7 +2994,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * contained in @a __s within this string. If found, returns * the index where it was found. If not found, returns npos. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR size_type find_first_not_of(const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT @@ -3013,7 +3013,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * other than @a __c within this string. If found, returns the * index where it was found. If not found, returns npos. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR size_type find_first_not_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT; @@ -3029,7 +3029,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * returns the index where it was found. If not found, returns * npos. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR size_type find_last_not_of(const basic_string& __str, size_type __pos = npos) const _GLIBCXX_NOEXCEPT @@ -3044,7 +3044,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * @return Index of last occurrence. */ template - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR _If_sv<_Tp, size_type> find_last_not_of(const _Tp& __svt, size_type __pos = npos) const noexcept(is_same<_Tp, __sv_type>::value) @@ -3066,7 +3066,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * If found, returns the index where it was found. If not found, * returns npos. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const _GLIBCXX_NOEXCEPT; @@ -3081,7 +3081,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * returns the index where it was found. If not found, returns * npos. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR size_type find_last_not_of(const _CharT* __s, size_type __pos = npos) const _GLIBCXX_NOEXCEPT @@ -3100,7 +3100,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * @a __c within this string. If found, returns the index where it was * found. If not found, returns npos. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR size_type find_last_not_of(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT; @@ -3117,7 +3117,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * short, use the remainder of the characters. If @a __pos is * beyond the end of the string, out_of_range is thrown. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR basic_string substr(size_type __pos = 0, size_type __n = npos) const { return basic_string(*this, @@ -3137,7 +3137,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * If the result of the comparison is nonzero returns it, * otherwise the shorter one is ordered first. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR int compare(const basic_string& __str) const { @@ -3158,7 +3158,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * @return Integer < 0, 0, or > 0. */ template - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR _If_sv<_Tp, int> compare(const _Tp& __svt) const noexcept(is_same<_Tp, __sv_type>::value) @@ -3183,7 +3183,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * @return Integer < 0, 0, or > 0. */ template - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR _If_sv<_Tp, int> compare(size_type __pos, size_type __n, const _Tp& __svt) const noexcept(is_same<_Tp, __sv_type>::value) @@ -3203,7 +3203,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * @return Integer < 0, 0, or > 0. */ template - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR _If_sv<_Tp, int> compare(size_type __pos1, size_type __n1, const _Tp& __svt, size_type __pos2, size_type __n2 = npos) const @@ -3234,7 +3234,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * result of the comparison is nonzero returns it, otherwise * the shorter one is ordered first. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR int compare(size_type __pos, size_type __n, const basic_string& __str) const { @@ -3271,7 +3271,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * If the result of the comparison is nonzero returns it, * otherwise the shorter one is ordered first. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR int compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2 = npos) const @@ -3302,7 +3302,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * comparison is nonzero returns it, otherwise the shorter one is * ordered first. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR int compare(const _CharT* __s) const _GLIBCXX_NOEXCEPT { @@ -3337,7 +3337,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * the comparison is nonzero returns it, otherwise the shorter * one is ordered first. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR int compare(size_type __pos, size_type __n1, const _CharT* __s) const { @@ -3376,7 +3376,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * NB: s must have at least n2 characters, '\\0' has * no special meaning. */ - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR int compare(size_type __pos, size_type __n1, const _CharT* __s, size_type __n2) const @@ -3392,43 +3392,49 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 } #if __cplusplus >= 202002L + [[nodiscard]] constexpr bool starts_with(basic_string_view<_CharT, _Traits> __x) const noexcept { return __sv_type(this->data(), this->size()).starts_with(__x); } + [[nodiscard]] constexpr bool starts_with(_CharT __x) const noexcept { return __sv_type(this->data(), this->size()).starts_with(__x); } - [[__gnu__::__nonnull__]] + [[nodiscard, __gnu__::__nonnull__]] constexpr bool starts_with(const _CharT* __x) const noexcept { return __sv_type(this->data(), this->size()).starts_with(__x); } + [[nodiscard]] constexpr bool ends_with(basic_string_view<_CharT, _Traits> __x) const noexcept { return __sv_type(this->data(), this->size()).ends_with(__x); } + [[nodiscard]] constexpr bool ends_with(_CharT __x) const noexcept { return __sv_type(this->data(), this->size()).ends_with(__x); } - [[__gnu__::__nonnull__]] + [[nodiscard, __gnu__::__nonnull__]] constexpr bool ends_with(const _CharT* __x) const noexcept { return __sv_type(this->data(), this->size()).ends_with(__x); } #endif // C++20 #if __cplusplus > 202002L + [[nodiscard]] constexpr bool contains(basic_string_view<_CharT, _Traits> __x) const noexcept { return __sv_type(this->data(), this->size()).contains(__x); } + [[nodiscard]] constexpr bool contains(_CharT __x) const noexcept { return __sv_type(this->data(), this->size()).contains(__x); } - [[__gnu__::__nonnull__]] + [[nodiscard, __gnu__::__nonnull__]] constexpr bool contains(const _CharT* __x) const noexcept { return __sv_type(this->data(), this->size()).contains(__x); } @@ -3483,7 +3489,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 * @return New string with value of @a __lhs followed by @a __rhs. */ template - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR basic_string<_CharT, _Traits, _Alloc> operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) @@ -3500,7 +3506,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 * @return New string with value of @a __lhs followed by @a __rhs. */ template - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR basic_string<_CharT,_Traits,_Alloc> operator+(const _CharT* __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs); @@ -3512,7 +3518,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 * @return New string with @a __lhs followed by @a __rhs. */ template - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR basic_string<_CharT,_Traits,_Alloc> operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs); @@ -3523,7 +3529,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 * @return New string with @a __lhs followed by @a __rhs. */ template - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR inline basic_string<_CharT, _Traits, _Alloc> operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const _CharT* __rhs) @@ -3540,7 +3546,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 * @return New string with @a __lhs followed by @a __rhs. */ template - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR inline basic_string<_CharT, _Traits, _Alloc> operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs) { @@ -3553,7 +3559,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 #if __cplusplus >= 201103L template - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR inline basic_string<_CharT, _Traits, _Alloc> operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) @@ -3567,7 +3573,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 { return std::move(__rhs.insert(0, __lhs)); } template - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR inline basic_string<_CharT, _Traits, _Alloc> operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, basic_string<_CharT, _Traits, _Alloc>&& __rhs) @@ -3590,28 +3596,28 @@ _GLIBCXX_END_NAMESPACE_CXX11 } template - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR inline basic_string<_CharT, _Traits, _Alloc> operator+(const _CharT* __lhs, basic_string<_CharT, _Traits, _Alloc>&& __rhs) { return std::move(__rhs.insert(0, __lhs)); } template - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR inline basic_string<_CharT, _Traits, _Alloc> operator+(_CharT __lhs, basic_string<_CharT, _Traits, _Alloc>&& __rhs) { return std::move(__rhs.insert(0, 1, __lhs)); } template - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR inline basic_string<_CharT, _Traits, _Alloc> operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, const _CharT* __rhs) { return std::move(__lhs.append(__rhs)); } template - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR inline basic_string<_CharT, _Traits, _Alloc> operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, _CharT __rhs) @@ -3626,7 +3632,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 * @return True if @a __lhs.compare(@a __rhs) == 0. False otherwise. */ template - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR inline bool operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) @@ -3643,7 +3649,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 * @return True if @a __lhs.compare(@a __rhs) == 0. False otherwise. */ template - _GLIBCXX20_CONSTEXPR + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR inline bool operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const _CharT* __rhs) @@ -3661,6 +3667,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 * greater than, or incomparable with `__rhs`. */ template + [[nodiscard]] constexpr auto operator<=>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) noexcept @@ -3675,6 +3682,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 * greater than, or incomparable with `__rhs`. */ template + [[nodiscard]] constexpr auto operator<=>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const _CharT* __rhs) noexcept @@ -3688,6 +3696,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 * @return True if @a __rhs.compare(@a __lhs) == 0. False otherwise. */ template + _GLIBCXX_NODISCARD inline bool operator==(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) @@ -3701,6 +3710,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 * @return True if @a __lhs.compare(@a __rhs) != 0. False otherwise. */ template + _GLIBCXX_NODISCARD inline bool operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) @@ -3714,6 +3724,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 * @return True if @a __rhs.compare(@a __lhs) != 0. False otherwise. */ template + _GLIBCXX_NODISCARD inline bool operator!=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) @@ -3726,6 +3737,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 * @return True if @a __lhs.compare(@a __rhs) != 0. False otherwise. */ template + _GLIBCXX_NODISCARD inline bool operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const _CharT* __rhs) @@ -3739,6 +3751,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 * @return True if @a __lhs precedes @a __rhs. False otherwise. */ template + _GLIBCXX_NODISCARD inline bool operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) @@ -3752,6 +3765,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 * @return True if @a __lhs precedes @a __rhs. False otherwise. */ template + _GLIBCXX_NODISCARD inline bool operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const _CharT* __rhs) @@ -3764,6 +3778,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 * @return True if @a __lhs precedes @a __rhs. False otherwise. */ template + _GLIBCXX_NODISCARD inline bool operator<(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) @@ -3777,6 +3792,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 * @return True if @a __lhs follows @a __rhs. False otherwise. */ template + _GLIBCXX_NODISCARD inline bool operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) @@ -3790,6 +3806,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 * @return True if @a __lhs follows @a __rhs. False otherwise. */ template + _GLIBCXX_NODISCARD inline bool operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const _CharT* __rhs) @@ -3802,6 +3819,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 * @return True if @a __lhs follows @a __rhs. False otherwise. */ template + _GLIBCXX_NODISCARD inline bool operator>(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) @@ -3815,6 +3833,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 * @return True if @a __lhs doesn't follow @a __rhs. False otherwise. */ template + _GLIBCXX_NODISCARD inline bool operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) @@ -3828,6 +3847,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 * @return True if @a __lhs doesn't follow @a __rhs. False otherwise. */ template + _GLIBCXX_NODISCARD inline bool operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const _CharT* __rhs) @@ -3840,6 +3860,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 * @return True if @a __lhs doesn't follow @a __rhs. False otherwise. */ template + _GLIBCXX_NODISCARD inline bool operator<=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) @@ -3853,6 +3874,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 * @return True if @a __lhs doesn't precede @a __rhs. False otherwise. */ template + _GLIBCXX_NODISCARD inline bool operator>=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) @@ -3866,6 +3888,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 * @return True if @a __lhs doesn't precede @a __rhs. False otherwise. */ template + _GLIBCXX_NODISCARD inline bool operator>=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const _CharT* __rhs) @@ -3878,6 +3901,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 * @return True if @a __lhs doesn't precede @a __rhs. False otherwise. */ template + _GLIBCXX_NODISCARD inline bool operator>=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) @@ -4060,6 +4084,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 // DR 1261. Insufficent overloads for to_string / to_wstring + _GLIBCXX_NODISCARD inline string to_string(int __val) #if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32 @@ -4074,6 +4099,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 return __str; } + _GLIBCXX_NODISCARD inline string to_string(unsigned __val) #if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32 @@ -4085,6 +4111,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 return __str; } + _GLIBCXX_NODISCARD inline string to_string(long __val) #if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32 @@ -4099,6 +4126,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 return __str; } + _GLIBCXX_NODISCARD inline string to_string(unsigned long __val) #if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32 @@ -4110,6 +4138,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 return __str; } + _GLIBCXX_NODISCARD inline string to_string(long long __val) { @@ -4122,6 +4151,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 return __str; } + _GLIBCXX_NODISCARD inline string to_string(unsigned long long __val) { @@ -4133,6 +4163,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 #if _GLIBCXX_USE_C99_STDIO // NB: (v)snprintf vs sprintf. + _GLIBCXX_NODISCARD inline string to_string(float __val) { @@ -4142,6 +4173,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 "%f", __val); } + _GLIBCXX_NODISCARD inline string to_string(double __val) { @@ -4151,6 +4183,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 "%f", __val); } + _GLIBCXX_NODISCARD inline string to_string(long double __val) { @@ -4202,40 +4235,47 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF // DR 1261. + _GLIBCXX_NODISCARD inline wstring to_wstring(int __val) { return __gnu_cxx::__to_xstring(&std::vswprintf, 4 * sizeof(int), L"%d", __val); } + _GLIBCXX_NODISCARD inline wstring to_wstring(unsigned __val) { return __gnu_cxx::__to_xstring(&std::vswprintf, 4 * sizeof(unsigned), L"%u", __val); } + _GLIBCXX_NODISCARD inline wstring to_wstring(long __val) { return __gnu_cxx::__to_xstring(&std::vswprintf, 4 * sizeof(long), L"%ld", __val); } + _GLIBCXX_NODISCARD inline wstring to_wstring(unsigned long __val) { return __gnu_cxx::__to_xstring(&std::vswprintf, 4 * sizeof(unsigned long), L"%lu", __val); } + _GLIBCXX_NODISCARD inline wstring to_wstring(long long __val) { return __gnu_cxx::__to_xstring(&std::vswprintf, 4 * sizeof(long long), L"%lld", __val); } + _GLIBCXX_NODISCARD inline wstring to_wstring(unsigned long long __val) { return __gnu_cxx::__to_xstring(&std::vswprintf, 4 * sizeof(unsigned long long), L"%llu", __val); } + _GLIBCXX_NODISCARD inline wstring to_wstring(float __val) { @@ -4245,6 +4285,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 L"%f", __val); } + _GLIBCXX_NODISCARD inline wstring to_wstring(double __val) { @@ -4254,6 +4295,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 L"%f", __val); } + _GLIBCXX_NODISCARD inline wstring to_wstring(long double __val) { @@ -4287,6 +4329,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __str_hash_base : public __hash_base { + [[__nodiscard__]] size_t operator()(const _StrT& __s) const noexcept { return _Hash_impl::hash(__s.data(), __s.length() * sizeof(_CharT)); } diff --git a/libstdc++-v3/include/std/string_view b/libstdc++-v3/include/std/string_view index 5b96ffeecd6..2604af2e9aa 100644 --- a/libstdc++-v3/include/std/string_view +++ b/libstdc++-v3/include/std/string_view @@ -129,7 +129,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr basic_string_view(const basic_string_view&) noexcept = default; - __attribute__((__nonnull__)) constexpr + [[__gnu__::__nonnull__]] + constexpr basic_string_view(const _CharT* __str) noexcept : _M_len{traits_type::length(__str)}, _M_str{__str} @@ -172,54 +173,64 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif // C++23 #endif // C++20 - constexpr basic_string_view& operator=(const basic_string_view&) noexcept = default; // [string.view.iterators], iterator support + [[nodiscard]] constexpr const_iterator begin() const noexcept { return this->_M_str; } + [[nodiscard]] constexpr const_iterator end() const noexcept { return this->_M_str + this->_M_len; } + [[nodiscard]] constexpr const_iterator cbegin() const noexcept { return this->_M_str; } + [[nodiscard]] constexpr const_iterator cend() const noexcept { return this->_M_str + this->_M_len; } + [[nodiscard]] constexpr const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(this->end()); } + [[nodiscard]] constexpr const_reverse_iterator rend() const noexcept { return const_reverse_iterator(this->begin()); } + [[nodiscard]] constexpr const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(this->end()); } + [[nodiscard]] constexpr const_reverse_iterator crend() const noexcept { return const_reverse_iterator(this->begin()); } // [string.view.capacity], capacity + [[nodiscard]] constexpr size_type size() const noexcept { return this->_M_len; } + [[nodiscard]] constexpr size_type length() const noexcept { return _M_len; } + [[nodiscard]] constexpr size_type max_size() const noexcept { @@ -227,12 +238,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION / sizeof(value_type) / 4; } - [[nodiscard]] constexpr bool + [[nodiscard]] + constexpr bool empty() const noexcept { return this->_M_len == 0; } // [string.view.access], element access + [[nodiscard]] constexpr const_reference operator[](size_type __pos) const noexcept { @@ -240,6 +253,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return *(this->_M_str + __pos); } + [[nodiscard]] constexpr const_reference at(size_type __pos) const { @@ -250,6 +264,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return *(this->_M_str + __pos); } + [[nodiscard]] constexpr const_reference front() const noexcept { @@ -257,6 +272,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return *this->_M_str; } + [[nodiscard]] constexpr const_reference back() const noexcept { @@ -264,6 +280,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return *(this->_M_str + this->_M_len - 1); } + [[nodiscard]] constexpr const_pointer data() const noexcept { return this->_M_str; } @@ -305,6 +322,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return __rlen; } + [[nodiscard]] constexpr basic_string_view substr(size_type __pos = 0, size_type __n = npos) const noexcept(false) { @@ -313,6 +331,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return basic_string_view{_M_str + __pos, __rlen}; } + [[nodiscard]] constexpr int compare(basic_string_view __str) const noexcept { @@ -323,10 +342,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return __ret; } + [[nodiscard]] constexpr int compare(size_type __pos1, size_type __n1, basic_string_view __str) const { return this->substr(__pos1, __n1).compare(__str); } + [[nodiscard]] constexpr int compare(size_type __pos1, size_type __n1, basic_string_view __str, size_type __pos2, size_type __n2) const @@ -334,14 +355,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return this->substr(__pos1, __n1).compare(__str.substr(__pos2, __n2)); } - __attribute__((__nonnull__)) constexpr int + [[nodiscard, __gnu__::__nonnull__]] + constexpr int compare(const _CharT* __str) const noexcept { return this->compare(basic_string_view{__str}); } - __attribute__((__nonnull__)) constexpr int + [[nodiscard, __gnu__::__nonnull__]] + constexpr int compare(size_type __pos1, size_type __n1, const _CharT* __str) const { return this->substr(__pos1, __n1).compare(basic_string_view{__str}); } + [[nodiscard]] constexpr int compare(size_type __pos1, size_type __n1, const _CharT* __str, size_type __n2) const noexcept(false) @@ -352,19 +376,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus > 201703L #define __cpp_lib_starts_ends_with 201711L + [[nodiscard]] constexpr bool starts_with(basic_string_view __x) const noexcept { return this->substr(0, __x.size()) == __x; } + [[nodiscard]] constexpr bool starts_with(_CharT __x) const noexcept { return !this->empty() && traits_type::eq(this->front(), __x); } - [[__gnu__::__nonnull__]] + [[nodiscard, __gnu__::__nonnull__]] constexpr bool starts_with(const _CharT* __x) const noexcept { return this->starts_with(basic_string_view(__x)); } + [[nodiscard]] constexpr bool ends_with(basic_string_view __x) const noexcept { @@ -374,11 +401,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION && traits_type::compare(end() - __xlen, __x.data(), __xlen) == 0; } + [[nodiscard]] constexpr bool ends_with(_CharT __x) const noexcept { return !this->empty() && traits_type::eq(this->back(), __x); } - [[__gnu__::__nonnull__]] + [[nodiscard, __gnu__::__nonnull__]] constexpr bool ends_with(const _CharT* __x) const noexcept { return this->ends_with(basic_string_view(__x)); } @@ -386,15 +414,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus > 202002L #define __cpp_lib_string_contains 202011L + [[nodiscard]] constexpr bool contains(basic_string_view __x) const noexcept { return this->find(__x) != npos; } + [[nodiscard]] constexpr bool contains(_CharT __x) const noexcept { return this->find(__x) != npos; } - [[__gnu__::__nonnull__]] + [[nodiscard, __gnu__::__nonnull__]] constexpr bool contains(const _CharT* __x) const noexcept { return this->find(__x) != npos; } @@ -402,99 +432,123 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // [string.view.find], searching + [[nodiscard]] constexpr size_type find(basic_string_view __str, size_type __pos = 0) const noexcept { return this->find(__str._M_str, __pos, __str._M_len); } + [[nodiscard]] constexpr size_type find(_CharT __c, size_type __pos = 0) const noexcept; + [[nodiscard]] constexpr size_type find(const _CharT* __str, size_type __pos, size_type __n) const noexcept; - __attribute__((__nonnull__)) constexpr size_type + [[nodiscard, __gnu__::__nonnull__]] + constexpr size_type find(const _CharT* __str, size_type __pos = 0) const noexcept { return this->find(__str, __pos, traits_type::length(__str)); } + [[nodiscard]] constexpr size_type rfind(basic_string_view __str, size_type __pos = npos) const noexcept { return this->rfind(__str._M_str, __pos, __str._M_len); } + [[nodiscard]] constexpr size_type rfind(_CharT __c, size_type __pos = npos) const noexcept; + [[nodiscard]] constexpr size_type rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept; - __attribute__((__nonnull__)) constexpr size_type + [[nodiscard, __gnu__::__nonnull__]] + constexpr size_type rfind(const _CharT* __str, size_type __pos = npos) const noexcept { return this->rfind(__str, __pos, traits_type::length(__str)); } + [[nodiscard]] constexpr size_type find_first_of(basic_string_view __str, size_type __pos = 0) const noexcept { return this->find_first_of(__str._M_str, __pos, __str._M_len); } + [[nodiscard]] constexpr size_type find_first_of(_CharT __c, size_type __pos = 0) const noexcept { return this->find(__c, __pos); } + [[nodiscard]] constexpr size_type find_first_of(const _CharT* __str, size_type __pos, size_type __n) const noexcept; - __attribute__((__nonnull__)) constexpr size_type + [[nodiscard, __gnu__::__nonnull__]] + constexpr size_type find_first_of(const _CharT* __str, size_type __pos = 0) const noexcept { return this->find_first_of(__str, __pos, traits_type::length(__str)); } + [[nodiscard]] constexpr size_type find_last_of(basic_string_view __str, size_type __pos = npos) const noexcept { return this->find_last_of(__str._M_str, __pos, __str._M_len); } + [[nodiscard]] constexpr size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept { return this->rfind(__c, __pos); } + [[nodiscard]] constexpr size_type find_last_of(const _CharT* __str, size_type __pos, size_type __n) const noexcept; - __attribute__((__nonnull__)) constexpr size_type + [[nodiscard, __gnu__::__nonnull__]] + constexpr size_type find_last_of(const _CharT* __str, size_type __pos = npos) const noexcept { return this->find_last_of(__str, __pos, traits_type::length(__str)); } + [[nodiscard]] constexpr size_type find_first_not_of(basic_string_view __str, size_type __pos = 0) const noexcept { return this->find_first_not_of(__str._M_str, __pos, __str._M_len); } + [[nodiscard]] constexpr size_type find_first_not_of(_CharT __c, size_type __pos = 0) const noexcept; + [[nodiscard]] constexpr size_type find_first_not_of(const _CharT* __str, size_type __pos, size_type __n) const noexcept; - __attribute__((__nonnull__)) constexpr size_type + [[nodiscard, __gnu__::__nonnull__]] + constexpr size_type find_first_not_of(const _CharT* __str, size_type __pos = 0) const noexcept { return this->find_first_not_of(__str, __pos, traits_type::length(__str)); } + [[nodiscard]] constexpr size_type find_last_not_of(basic_string_view __str, size_type __pos = npos) const noexcept { return this->find_last_not_of(__str._M_str, __pos, __str._M_len); } + [[nodiscard]] constexpr size_type find_last_not_of(_CharT __c, size_type __pos = npos) const noexcept; + [[nodiscard]] constexpr size_type find_last_not_of(const _CharT* __str, size_type __pos, size_type __n) const noexcept; - __attribute__((__nonnull__)) constexpr size_type + [[nodiscard, __gnu__::__nonnull__]] + constexpr size_type find_last_not_of(const _CharT* __str, size_type __pos = npos) const noexcept { @@ -539,12 +593,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // type (see N3766). template + [[nodiscard]] constexpr bool operator==(basic_string_view<_CharT, _Traits> __x, basic_string_view<_CharT, _Traits> __y) noexcept { return __x.size() == __y.size() && __x.compare(__y) == 0; } template + [[nodiscard]] constexpr bool operator==(basic_string_view<_CharT, _Traits> __x, __type_identity_t> __y) @@ -553,6 +609,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cpp_lib_three_way_comparison template + [[nodiscard]] constexpr auto operator<=>(basic_string_view<_CharT, _Traits> __x, basic_string_view<_CharT, _Traits> __y) noexcept @@ -560,6 +617,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __detail::__char_traits_cmp_cat<_Traits>(__x.compare(__y)); } template + [[nodiscard]] constexpr auto operator<=>(basic_string_view<_CharT, _Traits> __x, __type_identity_t> __y) @@ -568,18 +626,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __detail::__char_traits_cmp_cat<_Traits>(__x.compare(__y)); } #else template + [[nodiscard]] constexpr bool operator==(__type_identity_t> __x, basic_string_view<_CharT, _Traits> __y) noexcept { return __x.size() == __y.size() && __x.compare(__y) == 0; } template + [[nodiscard]] constexpr bool operator!=(basic_string_view<_CharT, _Traits> __x, basic_string_view<_CharT, _Traits> __y) noexcept { return !(__x == __y); } template + [[nodiscard]] constexpr bool operator!=(basic_string_view<_CharT, _Traits> __x, __type_identity_t> __y) @@ -587,18 +648,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return !(__x == __y); } template + [[nodiscard]] constexpr bool operator!=(__type_identity_t> __x, basic_string_view<_CharT, _Traits> __y) noexcept { return !(__x == __y); } template + [[nodiscard]] constexpr bool operator< (basic_string_view<_CharT, _Traits> __x, basic_string_view<_CharT, _Traits> __y) noexcept { return __x.compare(__y) < 0; } template + [[nodiscard]] constexpr bool operator< (basic_string_view<_CharT, _Traits> __x, __type_identity_t> __y) @@ -606,18 +670,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __x.compare(__y) < 0; } template + [[nodiscard]] constexpr bool operator< (__type_identity_t> __x, basic_string_view<_CharT, _Traits> __y) noexcept { return __x.compare(__y) < 0; } template + [[nodiscard]] constexpr bool operator> (basic_string_view<_CharT, _Traits> __x, basic_string_view<_CharT, _Traits> __y) noexcept { return __x.compare(__y) > 0; } template + [[nodiscard]] constexpr bool operator> (basic_string_view<_CharT, _Traits> __x, __type_identity_t> __y) @@ -625,18 +692,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __x.compare(__y) > 0; } template + [[nodiscard]] constexpr bool operator> (__type_identity_t> __x, basic_string_view<_CharT, _Traits> __y) noexcept { return __x.compare(__y) > 0; } template + [[nodiscard]] constexpr bool operator<=(basic_string_view<_CharT, _Traits> __x, basic_string_view<_CharT, _Traits> __y) noexcept { return __x.compare(__y) <= 0; } template + [[nodiscard]] constexpr bool operator<=(basic_string_view<_CharT, _Traits> __x, __type_identity_t> __y) @@ -644,18 +714,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __x.compare(__y) <= 0; } template + [[nodiscard]] constexpr bool operator<=(__type_identity_t> __x, basic_string_view<_CharT, _Traits> __y) noexcept { return __x.compare(__y) <= 0; } template + [[nodiscard]] constexpr bool operator>=(basic_string_view<_CharT, _Traits> __x, basic_string_view<_CharT, _Traits> __y) noexcept { return __x.compare(__y) >= 0; } template + [[nodiscard]] constexpr bool operator>=(basic_string_view<_CharT, _Traits> __x, __type_identity_t> __y) @@ -663,6 +736,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __x.compare(__y) >= 0; } template + [[nodiscard]] constexpr bool operator>=(__type_identity_t> __x, basic_string_view<_CharT, _Traits> __y) noexcept @@ -696,6 +770,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct hash : public __hash_base { + [[nodiscard]] size_t operator()(const string_view& __str) const noexcept { return std::_Hash_impl::hash(__str.data(), __str.length()); } @@ -709,6 +784,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct hash : public __hash_base { + [[nodiscard]] size_t operator()(const wstring_view& __s) const noexcept { return std::_Hash_impl::hash(__s.data(), @@ -724,6 +800,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct hash : public __hash_base { + [[nodiscard]] size_t operator()(const u8string_view& __str) const noexcept { return std::_Hash_impl::hash(__str.data(), __str.length()); } @@ -738,6 +815,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct hash : public __hash_base { + [[nodiscard]] size_t operator()(const u16string_view& __s) const noexcept { return std::_Hash_impl::hash(__s.data(), @@ -752,6 +830,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct hash : public __hash_base { + [[nodiscard]] size_t operator()(const u32string_view& __s) const noexcept { return std::_Hash_impl::hash(__s.data(), diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/capacity/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/1.cc index 45af457eb1c..1ae4d3da976 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/capacity/1.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/1.cc @@ -175,7 +175,7 @@ void test01() sz03 = str02.size(); sz04 = str02.length(); VERIFY( sz03 == sz04 ); - str02.c_str(); + (void) str02.c_str(); sz03 = str02.size(); sz04 = str02.length(); VERIFY( sz03 == sz04 ); diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/1.cc index 244a795298e..1da273b091e 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/1.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/1.cc @@ -74,15 +74,15 @@ void test01() sz01 = str01.size(); sz02 = str01.length(); VERIFY( sz01 == sz02 ); - str01.c_str(); + (void) str01.c_str(); sz01 = str01.size(); sz02 = str01.length(); VERIFY( sz01 == sz02 ); sz01 = str01.length(); - str01.c_str(); + (void) str01.c_str(); str011 = str01 + "_addendum_"; - str01.c_str(); + (void) str01.c_str(); sz02 = str01.length(); VERIFY( sz01 == sz02 ); sz02 = str011.length(); diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/1.cc index 5cb682ef810..6f03e346dfe 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/1.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/1.cc @@ -71,15 +71,15 @@ void test01() sz01 = str01.size(); sz02 = str01.length(); VERIFY( sz01 == sz02 ); - str01.c_str(); + (void) str01.c_str(); sz01 = str01.size(); sz02 = str01.length(); VERIFY( sz01 == sz02 ); sz01 = str01.length(); - str01.c_str(); + (void) str01.c_str(); str011 = str01 + L"_addendum_"; - str01.c_str(); + (void) str01.c_str(); sz02 = str01.length(); VERIFY( sz01 == sz02 ); sz02 = str011.length(); diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/self_move.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/self_move.cc index d37fe398f5d..ddd9aea867a 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/self_move.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/self_move.cc @@ -32,7 +32,7 @@ test(const char* s) String s3 __attribute__((unused)) = s1; s1 = std::move(s1); - s1.begin(); // causes COW string to "leak" + (void) s1.begin(); // causes COW string to "leak" s1 = std::move(s1); String s4 __attribute__((unused)) = s1; diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/1.cc index 7fb4323a006..5a176c0b088 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/1.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/1.cc @@ -53,7 +53,7 @@ void test01(void) cref cref3 = str01.at(csz01 - 1); VERIFY( cref3 == 'a' ); try { - str01.at(csz01); + (void) str01.at(csz01); VERIFY( false ); // Should not get here, as exception thrown. } catch(std::out_of_range& fail) { @@ -68,7 +68,7 @@ void test01(void) ref ref3 = str02.at(csz02 - 1); VERIFY( ref3 == 'a' ); try { - str02.at(csz02); + (void) str02.at(csz02); VERIFY( false ); // Should not get here, as exception thrown. } catch(std::out_of_range& fail) { diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/21674.cc b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/21674.cc index a5a129b42aa..3ff8d51edff 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/21674.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/21674.cc @@ -27,5 +27,5 @@ int main() { typedef std::string string_type; string_type s; - s[1]; // abort + (void) s[1]; // abort } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/1.cc index 9bb5dcbc7da..f9a07abe8c3 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/1.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/1.cc @@ -53,7 +53,7 @@ void test01(void) cref cref3 = str01.at(csz01 - 1); VERIFY( cref3 == L'a' ); try { - str01.at(csz01); + (void) str01.at(csz01); VERIFY( false ); // Should not get here, as exception thrown. } catch(std::out_of_range& fail) { @@ -68,7 +68,7 @@ void test01(void) ref ref3 = str02.at(csz02 - 1); VERIFY( ref3 == L'a' ); try { - str02.at(csz02); + (void) str02.at(csz02); VERIFY( false ); // Should not get here, as exception thrown. } catch(std::out_of_range& fail) { diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/21674.cc b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/21674.cc index 974e6b21cb0..fc023a8e93e 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/21674.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/21674.cc @@ -27,5 +27,5 @@ int main() { typedef std::wstring string_type; string_type s; - s[1]; // abort + (void) s[1]; // abort } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/lwg2758.cc b/libstdc++-v3/testsuite/21_strings/basic_string/lwg2758.cc index 45d514b04a7..a9dcd9ab421 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/lwg2758.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/lwg2758.cc @@ -40,6 +40,6 @@ int main() x.replace(0, 3, "foo", 0, 3); x.replace(0, 3, cs, 0, 3); x = "bar"; - x.compare(0, 3, "foo", 0, 3); - x.compare(0, 3, cs, 0, 3); + (void) x.compare(0, 3, "foo", 0, 3); + (void) x.compare(0, 3, cs, 0, 3); } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/lwg2946.cc b/libstdc++-v3/testsuite/21_strings/basic_string/lwg2946.cc index 3cbaf1782e2..6e308baa71e 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/lwg2946.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/lwg2946.cc @@ -29,12 +29,12 @@ int main() s.insert(0, {"abc", 1}); s.replace(0, 1, {"abc", 1}); s.replace(s.begin(), s.begin(), {"abc", 1}); - s.find({"abc", 1}); - s.rfind({"abc", 1}); - s.find_first_of({"abc", 1}); - s.find_last_of({"abc", 1}); - s.find_first_not_of({"abc", 1}); - s.find_last_not_of({"abc", 1}); - s.compare({"abc", 1}); - s.compare(0, 1, {"abc", 1}); + (void) s.find({"abc", 1}); + (void) s.rfind({"abc", 1}); + (void) s.find_first_of({"abc", 1}); + (void) s.find_last_of({"abc", 1}); + (void) s.find_first_not_of({"abc", 1}); + (void) s.find_last_not_of({"abc", 1}); + (void) s.compare({"abc", 1}); + (void) s.compare(0, 1, {"abc", 1}); } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/contains/nonnull.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/contains/nonnull.cc index e987cb7d297..41bb3911390 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/contains/nonnull.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/contains/nonnull.cc @@ -1,4 +1,4 @@ -// { dg-options "-std=gnu++23 -Wnonnull -O0" } +// { dg-options "-std=gnu++23 -Wnonnull -O0 -Wno-unused-result" } // { dg-do compile { target c++23 } } #include diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/ends_with/nonnull.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/ends_with/nonnull.cc index 1f2a156bace..32f3449b4e9 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/ends_with/nonnull.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/ends_with/nonnull.cc @@ -1,4 +1,4 @@ -// { dg-options "-std=gnu++20 -Wnonnull -O0" } +// { dg-options "-std=gnu++20 -Wnonnull -O0 -Wno-unused-result" } // { dg-do compile { target c++20 } } #include diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/starts_with/nonnull.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/starts_with/nonnull.cc index 8514359c877..9e0d6659e66 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/starts_with/nonnull.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/starts_with/nonnull.cc @@ -1,4 +1,4 @@ -// { dg-options "-std=gnu++20 -Wnonnull -O0" } +// { dg-options "-std=gnu++20 -Wnonnull -O0 -Wno-unused-result" } // { dg-do compile { target c++20 } } #include diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/1.cc index 704d2f69c9a..be3e41a3766 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/1.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/1.cc @@ -35,12 +35,12 @@ int test01(void) // 2:8-chars_8-chars_ // The following triggers -Wstringop-overread. See PR 103332. str1 = std::string("8-chars_") + "8-chars_"; - str1.c_str(); + (void) str1.c_str(); // printf("1:%s\n", str1.c_str()); VERIFY( str1 == "8-chars_8-chars_" ); str2 = str1 + "7-chars"; // printf("2:%s\n", str1.c_str()); //str1 is gone - str1.c_str(); + (void) str1.c_str(); VERIFY( str1 == "8-chars_8-chars_" ); return 0; } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/1.cc index 4020950cba7..df3ff7c9a52 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/1.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/1.cc @@ -32,11 +32,11 @@ int test01(void) // 1:8-chars_8-chars_ // 2:8-chars_8-chars_ str1 = std::wstring(L"8-chars_") + L"8-chars_"; - str1.c_str(); + (void) str1.c_str(); // wprintf("1:%s\n", str1.c_str()); str2 = str1 + L"7-chars"; // wprintf("2:%s\n", str1.c_str()); //str1 is gone - str1.c_str(); + (void) str1.c_str(); return 0; } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/capacity/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/capacity/1.cc index 0376d918fc6..3d162c60667 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string_view/capacity/1.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/capacity/1.cc @@ -137,7 +137,7 @@ test01() sz03 = str02.size(); sz04 = str02.length(); VERIFY( sz03 == sz04 ); - str02.data(); + (void) str02.data(); sz03 = str02.size(); sz04 = str02.length(); VERIFY( sz03 == sz04 ); diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/char/1.cc index 5de62ec3746..b27e7d7dcfc 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/char/1.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/char/1.cc @@ -49,7 +49,7 @@ test01() VERIFY( cref3 == 'a' ); try { - str01.at(csz01); + (void) str01.at(csz01); VERIFY( false ); // Should not get here, as exception thrown. } catch (std::out_of_range& fail) diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/char/2.cc index e8f9db2b6c5..834d3f626de 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/char/2.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/char/2.cc @@ -27,5 +27,5 @@ main() { typedef std::string_view string_view_type; string_view_type s; - s[0]; // abort + (void) s[0]; // abort } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/wchar_t/1.cc index 9877cd8cf41..e9df8720fdc 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/wchar_t/1.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/wchar_t/1.cc @@ -49,7 +49,7 @@ test01() VERIFY( cref3 == L'a' ); try { - str01.at(csz01); + (void) str01.at(csz01); VERIFY( false ); // Should not get here, as exception thrown. } catch (std::out_of_range& fail) diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/wchar_t/2.cc index 23daa7ab1f2..840de84f2cf 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/wchar_t/2.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/wchar_t/2.cc @@ -29,5 +29,5 @@ main() { typedef std::wstring_view string_view_type; string_view_type s; - s[0]; // abort + (void) s[0]; // abort } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/contains/nonnull.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/contains/nonnull.cc index c0d274f095b..fafadcca01c 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/contains/nonnull.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/contains/nonnull.cc @@ -1,4 +1,4 @@ -// { dg-options "-std=gnu++23 -Wnonnull -O0" } +// { dg-options "-std=gnu++23 -Wnonnull -O0 -Wno-unused-result" } // { dg-do compile { target c++23 } } #include diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/ends_with/nonnull.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/ends_with/nonnull.cc index 09a99978a37..50437bb448a 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/ends_with/nonnull.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/ends_with/nonnull.cc @@ -1,4 +1,4 @@ -// { dg-options "-std=gnu++20 -Wnonnull -O0" } +// { dg-options "-std=gnu++20 -Wnonnull -O0 -Wno-unused-result" } // { dg-do compile { target c++20 } } #include diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/starts_with/nonnull.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/starts_with/nonnull.cc index c47f1dae832..fedba28afa3 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/starts_with/nonnull.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/starts_with/nonnull.cc @@ -1,4 +1,4 @@ -// { dg-options "-std=gnu++20 -Wnonnull -O0" } +// { dg-options "-std=gnu++20 -Wnonnull -O0 -Wno-unused-result" } // { dg-do compile { target c++20 } } #include diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/sputbackc/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/sputbackc/char/1.cc index 1e8c5fd46d7..2296fd1278f 100644 --- a/libstdc++-v3/testsuite/27_io/basic_stringbuf/sputbackc/char/1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/sputbackc/char/1.cc @@ -41,18 +41,18 @@ void test04() // PUT strb_03.str(str_01); //reset - strb_03.str().length(); - strb_03.str().length(); + (void) strb_03.str().length(); + (void) strb_03.str().length(); // streamsize sputn(const char_typs* s, streamsize n) // write up to n chars to out_cur from s, returning number assigned // NB *sputn will happily put '\0' into your stream if you give it a chance* str_tmp = strb_03.str(); - str_tmp.length(); + (void) str_tmp.length(); strb_03.sputn("racadabras", 10);//"abracadabras or what?" - strb_03.str().length(); + (void) strb_03.str().length(); strb_03.sputn(", i wanna reach out and", 10); - strb_03.str().length(); + (void) strb_03.str().length(); str_tmp = strb_02.str(); strb_02.sputn("racadabra", 10); diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/sputbackc/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/sputbackc/wchar_t/1.cc index 6acc0f2423b..c44a535350d 100644 --- a/libstdc++-v3/testsuite/27_io/basic_stringbuf/sputbackc/wchar_t/1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/sputbackc/wchar_t/1.cc @@ -41,18 +41,18 @@ void test04() // PUT strb_03.str(str_01); //reset - strb_03.str().length(); - strb_03.str().length(); + (void) strb_03.str().length(); + (void) strb_03.str().length(); // streamsize sputn(const char_typs* s, streamsize n) // write up to n chars to out_cur from s, returning number assigned // NB *sputn will happily put '\0' into your stream if you give it a chance* str_tmp = strb_03.str(); - str_tmp.length(); + (void) str_tmp.length(); strb_03.sputn(L"racadabras", 10);//"abracadabras or what?" - strb_03.str().length(); + (void) strb_03.str().length(); strb_03.sputn(L", i wanna reach out and", 10); - strb_03.str().length(); + (void) strb_03.str().length(); str_tmp = strb_02.str(); strb_02.sputn(L"racadabra", 10); diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/sungetc/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/sungetc/char/1.cc index 2a3a28b27d9..b4cdb17f3b7 100644 --- a/libstdc++-v3/testsuite/27_io/basic_stringbuf/sungetc/char/1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/sungetc/char/1.cc @@ -41,18 +41,18 @@ void test04() // PUT strb_03.str(str_01); //reset - strb_03.str().length(); - strb_03.str().length(); + (void) strb_03.str().length(); + (void) strb_03.str().length(); // streamsize sputn(const char_typs* s, streamsize n) // write up to n chars to out_cur from s, returning number assigned // NB *sputn will happily put '\0' into your stream if you give it a chance* str_tmp = strb_03.str(); - str_tmp.length(); + (void) str_tmp.length(); strb_03.sputn("racadabras", 10);//"abracadabras or what?" - strb_03.str().length(); + (void) strb_03.str().length(); strb_03.sputn(", i wanna reach out and", 10); - strb_03.str().length(); + (void) strb_03.str().length(); str_tmp = strb_02.str(); strb_02.sputn("racadabra", 10); diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/sungetc/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/sungetc/wchar_t/1.cc index 5f20e2cab1f..eb0ae5e5efa 100644 --- a/libstdc++-v3/testsuite/27_io/basic_stringbuf/sungetc/wchar_t/1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/sungetc/wchar_t/1.cc @@ -41,18 +41,18 @@ void test04() // PUT strb_03.str(str_01); //reset - strb_03.str().length(); - strb_03.str().length(); + (void) strb_03.str().length(); + (void) strb_03.str().length(); // streamsize sputn(const char_typs* s, streamsize n) // write up to n chars to out_cur from s, returning number assigned // NB *sputn will happily put '\0' into your stream if you give it a chance* str_tmp = strb_03.str(); - str_tmp.length(); + (void) str_tmp.length(); strb_03.sputn(L"racadabras", 10);//"abracadabras or what?" - strb_03.str().length(); + (void) strb_03.str().length(); strb_03.sputn(L", i wanna reach out and", 10); - strb_03.str().length(); + (void) strb_03.str().length(); str_tmp = strb_02.str(); strb_02.sputn(L"racadabra", 10);