From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 9BF09385B524 for ; Wed, 22 Mar 2023 17:49:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9BF09385B524 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679507391; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CCVuVAa5yGs1kEKzZOsj/u/crx5jQDUC9l1s1UyAwxs=; b=VxpA/pbfUVg2QWxasGsN3iCuzZScKakES3/DBhOeKN/2MZ4Waqux8ArT2hQURp6uwkUUhp vgqPvlDddgJTx+izfl2zFjCPiDMnRad+uC+7MsRu1FeZMRMCiScHv9porcohjqOEOygLMf 7f10axTaLZENjmqK357dN6htS3V0hfs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-558-LAajULCnNIq8b0Mhig4L0Q-1; Wed, 22 Mar 2023 13:49:48 -0400 X-MC-Unique: LAajULCnNIq8b0Mhig4L0Q-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E3D5E185A78F; Wed, 22 Mar 2023 17:49:47 +0000 (UTC) Received: from localhost (unknown [10.33.36.149]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD556492C13; Wed, 22 Mar 2023 17:49:47 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Add allocator-extended constructors to std::match_results (LWG 2195) Date: Wed, 22 Mar 2023 17:49:47 +0000 Message-Id: <20230322174947.407957-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.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_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Tested powerpc64le-linux, pushed to trunk. -- >8-- This was approved in Issaquah last month. libstdc++-v3/ChangeLog: * include/bits/regex.h (match_results): Add allocator-extended copy and move constructors, as per LWG 2195. * testsuite/28_regex/match_results/ctors/char/alloc.cc: New test. --- libstdc++-v3/include/bits/regex.h | 10 ++++ .../match_results/ctors/char/alloc.cc | 56 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 libstdc++-v3/testsuite/28_regex/match_results/ctors/char/alloc.cc diff --git a/libstdc++-v3/include/bits/regex.h b/libstdc++-v3/include/bits/regex.h index 386f4be9f4a..79903fad1e5 100644 --- a/libstdc++-v3/include/bits/regex.h +++ b/libstdc++-v3/include/bits/regex.h @@ -1826,6 +1826,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 */ ~match_results() = default; + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2195. Missing constructors for match_results + + match_results(const match_results& __m, const _Alloc& __a) + : _Base_type(__m, __a) { } + + match_results(match_results&& __m, const _Alloc& __a) + noexcept(noexcept(_Base_type(std::move(__m), __a))) + : _Base_type(std::move(__m), __a) { } + ///@} // 28.10.2, state: diff --git a/libstdc++-v3/testsuite/28_regex/match_results/ctors/char/alloc.cc b/libstdc++-v3/testsuite/28_regex/match_results/ctors/char/alloc.cc new file mode 100644 index 00000000000..bb5e7a91bd7 --- /dev/null +++ b/libstdc++-v3/testsuite/28_regex/match_results/ctors/char/alloc.cc @@ -0,0 +1,56 @@ +// { dg-do run { target c++11 } } + +#include +#include +#include + +// LWG 2195. Missing constructors for match_results + +void +test01() +{ + using Alloc = std::cmatch::allocator_type; + std::cmatch m1; + std::cmatch m2(m1, m1.get_allocator()); + VERIFY( m2 == m1 ); + + static_assert( ! std::is_nothrow_constructible(), + "Allocator-extended copy ctor is potentially-throwing" ); + + std::cmatch m3(std::move(m1), m2.get_allocator()); + VERIFY( m3 == m2 ); + + // Libstdc++ extension: + static_assert( std::is_nothrow_constructible(), + "Allocator-extended move ctor is non-throwing" ); +} + +void +test02() +{ + using Alloc = __gnu_test::uneq_allocator; + using MR = std::match_results; + + MR m1(Alloc(1)); + MR m2(m1, Alloc(2)); + VERIFY( m2 == m1 ); + + static_assert( ! std::is_nothrow_constructible(), + "Allocator-extended copy ctor is potentially-throwing" ); + + MR m3(std::move(m1), Alloc(3)); + VERIFY( m3 == m2 ); + + static_assert( ! std::is_nothrow_constructible(), + "Allocator-extended move ctor is potentially-throwing" ); +} + +int main() +{ + test01(); + test02(); +} -- 2.39.2