From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2136) id 01B223945C23; Wed, 17 Jun 2020 19:41:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 01B223945C23 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1592422867; bh=6JLNDV7tUNNj9A9ehcBDsFI3ea1iIAGzlLsLlJGp5rU=; h=From:To:Subject:Date:From; b=mjPVkScq+8flwHhjP1Xm1nP0/aT0jbTXny+Y8axSqhKxZP/ms13iFkcsD0TAiWVIe mOJIPz9fbc1F2mDXbXxPqBCnC+koCBt9a/DfI4JJHTLNJSDjotE2NrltpZT7tNWNoe CbiZLzt2uZIIdRK0HklmEelJSDHNor7v7zlDtsTE= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Aldy Hernandez To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc/devel/ranger] libstdc++: Add default constructor to net::service_already_exists (PR 94199) X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/devel/ranger X-Git-Oldrev: 447d196e75d97a9ac7c6a548dc9d0fe367adf6be X-Git-Newrev: c62f5e6e1f457462b1cea74792833821bbea64bb Message-Id: <20200617194107.01B223945C23@sourceware.org> Date: Wed, 17 Jun 2020 19:41:06 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jun 2020 19:41:07 -0000 https://gcc.gnu.org/g:c62f5e6e1f457462b1cea74792833821bbea64bb 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: --- libstdc++-v3/ChangeLog | 8 +++++ libstdc++-v3/include/experimental/executor | 9 +++++- .../net/execution_context/make_service.cc | 36 ++++++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 5cf329fdda7..66acdb08cda 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2020-03-16 Jonathan Wakely + + 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. + 2020-03-12 Jonathan Wakely * testsuite/tr1/8_c_compatibility/cstdlib/functions.cc: Do not pass 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); +}