From patchwork Tue Jan 23 23:53:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 191267 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2553:b0:103:945f:af90 with SMTP id p19csp698089dyi; Tue, 23 Jan 2024 16:57:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IHBOGATEN36quKOIsO0AyhOE22CW6+pfgYB9W+4GO3J8d8OCXI4xuzR/ydGOwtOdrO5bI8h X-Received: by 2002:a05:620a:35e:b0:783:76ac:fd8f with SMTP id t30-20020a05620a035e00b0078376acfd8fmr7934941qkm.131.1706057867995; Tue, 23 Jan 2024 16:57:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706057867; cv=pass; d=google.com; s=arc-20160816; b=SubGGUmRBKeX8K/kseU9vjx1YtetSNBYPoHNTmdGVDpqBggVDaxzGvipmH24iV6L0y NvOYmXd6WB/pTz4cwS9V3u4ycTUeROOI9M1ExuP7EgiPDzkOV4LDPd6I4pH1nv+in7KI +hf8zto6E4lnzaurReHypdJDbOSEWvrr7niKbVLnIzhvwtohc6d1ISb/GDVNEX4LwL5S nk7Kk5xSQFuoe1D3wQ7zpoggT7QcmhVZnVEOOl2JqGaAGJghItbZZjyNaVyMCtqsXtQS KwvR9CVO93zEK9cAk6kGoxafZuUr1jdUnUGMV5r2sXllVGMi4ADIFk6oCJzdCUlsBlV2 kH9A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=ly5INfAkaeqe7VvG2pUVLuNtoWw7SqK8LiLTDYjwqkI=; fh=EVSvWd94bH3+6DLHxQIQnUkCnGLOu/mRCJOpcO366zA=; b=Safxrp2z1Lxri/MSKiOsWtWTrp8r5U9OMgQUeUgEq4mmRZi6kO1ElZOpjmzljo5XXO XiK7xJ0vR3hzkFIeoEN7ixcOkAw+tSVIj6iMeb7NxtCMBJJwydxmLaboCAu6hvpVWoqb GHuUr4JpG42dZ85yOQjVmaLva5Q+jwDTuTVBolofPcQmic/e66nUOrjO5wmhZCbN/8XE vxg7oFhyzNBt8t/cOIEL/zwFivEkN5753CBOO0sHJBhlHLRqsaTOd7yi3p29LabPUxIb XY+doVaQeg4Pn0eNnl6QhrvOLQtCjo0CoSYyVXB/LF6bkszuu3j7ocHuLGiG6t8mpxVe 24eQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RjEju5yL; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id d29-20020a05620a205d00b007839054efc6si8925615qka.437.2024.01.23.16.57.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 16:57:47 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RjEju5yL; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5B9813857C43 for ; Tue, 23 Jan 2024 23:54:17 +0000 (GMT) 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.133.124]) by sourceware.org (Postfix) with ESMTPS id F168B3858CDA for ; Tue, 23 Jan 2024 23:53:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F168B3858CDA Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F168B3858CDA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706053992; cv=none; b=qVm4FGFukCurqsgDOLe7LKp51I7S02Zjbng++S6Rm0iZijzqtgny2VjJ84EYF3HzB7hMK+fJ2eWKDKMRGnUA/pu58IQp3i3f2l6KSwU66c4T5C6Z50MnsEvJm8/sQLyKxUJ65nxn35OWZeBVZ5Rmz8DwZAdOrG40JATIx9rSqN0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706053992; c=relaxed/simple; bh=W8p48NjCseEH/ZocN8NE71qETNtCsn/pTWV65XIVqSw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=uDnjvHDWt52JmqIkuaEHzbZMLyRVyc5WH83Qw+Ifa5pBs1bVntyeGrAzmlmcOA69l/uLJvaXJU7IbN2ZU0Mni6s4HKhz3T4h6ENbwn7JPFXxUcRYXVkqWrd0QusnmLBBc3bQLfzbHszwyLi7d3f5+wHZOKxfL93j9iFVVc+Aluk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706053989; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ly5INfAkaeqe7VvG2pUVLuNtoWw7SqK8LiLTDYjwqkI=; b=RjEju5yL1hk8e1uQEegW0SPzVnYJD1MS0bv6UgHRgB/eZFTqWOzBxW7L2tkcD8WObQyfD/ pqz55IfFnX2e3PIImKuLwWgdktvri5gJMyY9Va37+yHmIMl1bW3Kb/jHoJfjbAwRv51liC oYZE1t2JBg6bRf0jpiNBG4eaT26MLyk= Received: from mail-yw1-f200.google.com (mail-yw1-f200.google.com [209.85.128.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-550-CCkgpW1jM1-Yp_19pEOLjw-1; Tue, 23 Jan 2024 18:53:08 -0500 X-MC-Unique: CCkgpW1jM1-Yp_19pEOLjw-1 Received: by mail-yw1-f200.google.com with SMTP id 00721157ae682-5eba564eb3fso81385177b3.1 for ; Tue, 23 Jan 2024 15:53:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706053986; x=1706658786; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ly5INfAkaeqe7VvG2pUVLuNtoWw7SqK8LiLTDYjwqkI=; b=aMcDEpBRhh/W6yQIUqOzSOu0FvEC/5nksq4SoSBUSLvgmcMBhLWgGgMHAjC0+eQRRl W6zJYpLRijLDLdEi3qT9xt8YXpIP1ONdby95HLnwePy0tfW95ufDrw3d0BsPKZOBVl90 63IjblGDHB1G3G95+jnRC1p8eBqGO+DxcEW0GsWC9SchhImqlGa6I3ycMh6g6ikD4M4T vzvGHRblpEXBUmpg62P7MTZg4QTt29qWf77OdptrV0oJLpLnUC3BRR2Ce0WF7o7RjK0k +Ht7ehbuz9fcj7LbRdi5eYKB358RsrqPQUFEeJ5nIMnTs8RRqS2EYoukCqQVyOQidYIA c6bg== X-Gm-Message-State: AOJu0Yz/f1hmslCHHx2IFNmSf9GeDRM6Shr1Pul/ow6wS938/tBZsuqx 01ZRquvlZfusyRCwZ7tgrYvwUlaMVjmCmvLh//wSTsWk5SDiR8f+H6bJMeSk3SSwQNrEYT/4cCK p1GBqYUjOINK7OdSgvYfhdBRpiydWPfU70VZXHs+Or/vW1jmFkK0jBOL+QeC4+SwdZGMFH4VQqn b/iz7r3AHpDdvyvEyImZAoEg3vyWA2uB3GLT6C X-Received: by 2002:a25:adda:0:b0:db7:dacf:ed96 with SMTP id d26-20020a25adda000000b00db7dacfed96mr4691664ybe.119.1706053986018; Tue, 23 Jan 2024 15:53:06 -0800 (PST) X-Received: by 2002:a25:adda:0:b0:db7:dacf:ed96 with SMTP id d26-20020a25adda000000b00db7dacfed96mr4691654ybe.119.1706053985549; Tue, 23 Jan 2024 15:53:05 -0800 (PST) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id j7-20020a0ceb07000000b00681092cb7b4sm3888576qvp.103.2024.01.23.15.53.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 15:53:05 -0800 (PST) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Patrick Palka Subject: [PATCH 1/2] libstdc++/pair: Define _S_const_assignable helper for C++20 Date: Tue, 23 Jan 2024 18:53:02 -0500 Message-ID: <20240123235303.1540890-1-ppalka@redhat.com> X-Mailer: git-send-email 2.43.0.386.ge02ecfcc53 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788931334790185700 X-GMAIL-MSGID: 1788931334790185700 This is consistent with std::tuple's __const_assignable member function, and will be reused when implementing the new pair::operator= overloads from P2165R4. libstdc++-v3/ChangeLog: * include/bits/stl_pair.h (pair::_S_const_assignable): Define, factored out from ... (pair::operator=): ... the constraints of the const overloads. --- libstdc++-v3/include/bits/stl_pair.h | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/libstdc++-v3/include/bits/stl_pair.h b/libstdc++-v3/include/bits/stl_pair.h index acd0c7b58f9..b81b479ad43 100644 --- a/libstdc++-v3/include/bits/stl_pair.h +++ b/libstdc++-v3/include/bits/stl_pair.h @@ -404,6 +404,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return false; } + template + static constexpr bool + _S_const_assignable() + { + if constexpr (is_assignable_v) + return is_assignable_v; + return false; + } + template static constexpr bool _S_nothrow_assignable() @@ -468,8 +477,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Copy assignment operator (const) constexpr const pair& operator=(const pair& __p) const - requires is_copy_assignable_v - && is_copy_assignable_v + requires (_S_const_assignable()) { first = __p.first; second = __p.second; @@ -479,8 +487,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Move assignment operator (const) constexpr const pair& operator=(pair&& __p) const - requires is_assignable_v - && is_assignable_v + requires (_S_const_assignable()) { first = std::forward(__p.first); second = std::forward(__p.second); @@ -491,8 +498,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template constexpr const pair& operator=(const pair<_U1, _U2>& __p) const - requires is_assignable_v - && is_assignable_v + requires (_S_const_assignable()) { first = __p.first; second = __p.second; @@ -503,8 +509,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template constexpr const pair& operator=(pair<_U1, _U2>&& __p) const - requires is_assignable_v - && is_assignable_v + requires (_S_const_assignable<_U1, _U2>()) { first = std::forward<_U1>(__p.first); second = std::forward<_U2>(__p.second);