From patchwork Mon Mar 16 22:54:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 1255927 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: 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=ma5e+gy8; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48hBT91rMzz9sNg for ; Tue, 17 Mar 2020 09:54:51 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E0526389F4EE; Mon, 16 Mar 2020 22:54:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E0526389F4EE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1584399284; bh=TzppWyj/y/5HuvdYUPM9EcR8l4WRdV5LOzBNZMpTuU8=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ma5e+gy85AtOmYPky+wduFPLoKQHdMiKLaXtkdsyrmQdY+DWtZoNy+ZaaLZIxJh/v gln7bgzbg7kcrEYVuS+/NaijTi/7KuljmH8P6c9Q037IliOPTFpxVd515WT5AVgCQD j/1yRvSpOCzErdnv0OgEuX4B6OKAzdlnpoYLSgRM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) by sourceware.org (Postfix) with ESMTP id 825D83871029 for ; Mon, 16 Mar 2020 22:54:40 +0000 (GMT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-353-AHrXSEO_PGCg3VPultE5LA-1; Mon, 16 Mar 2020 18:54:37 -0400 X-MC-Unique: AHrXSEO_PGCg3VPultE5LA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 82FE7477; Mon, 16 Mar 2020 22:54:36 +0000 (UTC) Received: from localhost (unknown [10.33.36.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2FBAA60BE2; Mon, 16 Mar 2020 22:54:35 +0000 (UTC) Date: Mon, 16 Mar 2020 22:54:35 +0000 To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Add default constructor to net::service_already_exists (PR 94199) Message-ID: <20200316225435.GA3755249@redhat.com> MIME-Version: 1.0 X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-25.2 required=5.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" The service_already_exists exception type specified in the TS doesn't have any constructors defined. Since its base class isn't default constructible, that means has no usable constructors. This may be a defect in the TS. This patch fixes it by adding a default constructor, but making it private. The make_service function is declared as a friend to be able to call that private constructor. PR libstdc++/94199 * include/experimental/executor (service_already_exists): Add default constructor. Declare make_service to be a friend. * testsuite/experimental/net/execution_context/make_service.cc: New test. Tested powerpc64le-linux, committed to master. I'll backport it to gcc-9 too. commit c62f5e6e1f457462b1cea74792833821bbea64bb Author: Jonathan Wakely Date: Mon Mar 16 22:53:42 2020 +0000 libstdc++: Add default constructor to net::service_already_exists (PR 94199) The service_already_exists exception type specified in the TS doesn't have any constructors defined. Since its base class isn't default constructible, that means has no usable constructors. This may be a defect in the TS. This patch fixes it by adding a default constructor, but making it private. The make_service function is declared as a friend to be able to call that private constructor. PR libstdc++/94199 * include/experimental/executor (service_already_exists): Add default constructor. Declare make_service to be a friend. * testsuite/experimental/net/execution_context/make_service.cc: New test. diff --git a/libstdc++-v3/include/experimental/executor b/libstdc++-v3/include/experimental/executor index 5577623bb47..6955ead6bf5 100644 --- a/libstdc++-v3/include/experimental/executor +++ b/libstdc++-v3/include/experimental/executor @@ -127,7 +127,14 @@ inline namespace v1 /// An extensible, type-safe, polymorphic set of services. class execution_context; - class service_already_exists : public logic_error { }; + class service_already_exists : public logic_error + { + template + friend _Service& + make_service(execution_context&, _Args&&...); + + service_already_exists() : logic_error("service already exists") { } + }; template struct is_executor; diff --git a/libstdc++-v3/testsuite/experimental/net/execution_context/make_service.cc b/libstdc++-v3/testsuite/experimental/net/execution_context/make_service.cc new file mode 100644 index 00000000000..f134add48b5 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/net/execution_context/make_service.cc @@ -0,0 +1,36 @@ +// Copyright (C) 2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do compile { target c++14 } } + +#include + +namespace net = std::experimental::net; + +struct S : net::execution_context::service +{ + using key_type = S; + + S(net::execution_context&); + + void shutdown() noexcept override { } +}; + +void test01(net::execution_context& c) +{ + net::make_service(c); +}