From patchwork Tue Nov 16 16:45:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1555949 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=DjNf8Oeo; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HtsQW5n4rz9sR4 for ; Wed, 17 Nov 2021 03:46:26 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 53ECA385AC37 for ; Tue, 16 Nov 2021 16:46:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 53ECA385AC37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1637081184; bh=UA8vvBJen20onElTrQUdsiQY4hHoHZFv5wwg9RZHH8o=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=DjNf8Oeo8YzuY3JTkSpSVDg+pO4Cmvzs0xld3uYJolHztBc4xpmcykJiZubThg0qx jSI1IYRWZxfU6rfYMDH4YpnE+E5HFC1Xo4qYBma0oldv7mpSLzD8zFqX1pYOQwaMxN b220xZSN8T24sqdaqiUqhSuN0PG0d6ARqnsqj6KU= 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 184683858003 for ; Tue, 16 Nov 2021 16:45:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 184683858003 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-3-Vm0lMzJQOAyPA8g-MJRPqw-1; Tue, 16 Nov 2021 11:45:29 -0500 X-MC-Unique: Vm0lMzJQOAyPA8g-MJRPqw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 824BE875048; Tue, 16 Nov 2021 16:45:28 +0000 (UTC) Received: from localhost (unknown [10.33.36.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 318F070886; Tue, 16 Nov 2021 16:45:27 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed 1/2] libstdc++: Use hidden friends for vector::reference swap overloads Date: Tue, 16 Nov 2021 16:45:26 +0000 Message-Id: <20211116164527.3872136-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-14.1 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, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Tested x86_64-linux, committed to trunk. These swap overloads are non-standard, but are needed to make swap work for vector::reference rvalues. They don't need to be called explicitly, only via ADL, so hide them from normal lookup. This is what I've proposed as the resolution to LWG 3638. libstdc++-v3/ChangeLog: * include/bits/stl_bvector.h (swap(_Bit_reference, _Bit_reference)) (swap(_Bit_reference, bool&), swap(bool&, _Bit_reference)): Define as hidden friends of _Bit_reference. --- libstdc++-v3/include/bits/stl_bvector.h | 50 ++++++++++++------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h index 381c47b6132..68070685baf 100644 --- a/libstdc++-v3/include/bits/stl_bvector.h +++ b/libstdc++-v3/include/bits/stl_bvector.h @@ -125,36 +125,36 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER void flip() _GLIBCXX_NOEXCEPT { *_M_p ^= _M_mask; } - }; #if __cplusplus >= 201103L - _GLIBCXX20_CONSTEXPR - inline void - swap(_Bit_reference __x, _Bit_reference __y) noexcept - { - bool __tmp = __x; - __x = __y; - __y = __tmp; - } + _GLIBCXX20_CONSTEXPR + friend void + swap(_Bit_reference __x, _Bit_reference __y) noexcept + { + bool __tmp = __x; + __x = __y; + __y = __tmp; + } - _GLIBCXX20_CONSTEXPR - inline void - swap(_Bit_reference __x, bool& __y) noexcept - { - bool __tmp = __x; - __x = __y; - __y = __tmp; - } + _GLIBCXX20_CONSTEXPR + friend void + swap(_Bit_reference __x, bool& __y) noexcept + { + bool __tmp = __x; + __x = __y; + __y = __tmp; + } - _GLIBCXX20_CONSTEXPR - inline void - swap(bool& __x, _Bit_reference __y) noexcept - { - bool __tmp = __x; - __x = __y; - __y = __tmp; - } + _GLIBCXX20_CONSTEXPR + friend void + swap(bool& __x, _Bit_reference __y) noexcept + { + bool __tmp = __x; + __x = __y; + __y = __tmp; + } #endif + }; struct _Bit_iterator_base : public std::iterator