On 16/03/20 22:54 +0000, Jonathan Wakely wrote:
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.
LWG preferred to make the constrcutor public, so this patch does that.
Tested x86_64-linux, committed to master.
commit 00082ff88cf4e25fc1041e9effd1c92fbaaa8d62
Author: Jonathan Wakely <jwak...@redhat.com>
Date: Fri Apr 24 14:15:51 2020 +0100
libstdc++: Make net::service_already_exists default constructible
The LWG issue I created is Tentatively Ready and proposes to declare a
public default constructor, rather than the private one I added
recently.
* include/experimental/executor (service_already_exists): Make default
constructor public (LWG 3414).
* testsuite/experimental/net/execution_context/make_service.cc: Check
the service_already_exists can be default constructed.
diff --git a/libstdc++-v3/include/experimental/executor b/libstdc++-v3/include/experimental/executor
index fa39eaa0468..3560e345e8a 100644
--- a/libstdc++-v3/include/experimental/executor
+++ b/libstdc++-v3/include/experimental/executor
@@ -129,10 +129,9 @@ inline namespace v1
class service_already_exists : public logic_error
{
- template<typename _Service, typename... _Args>
- friend _Service&
- make_service(execution_context&, _Args&&...);
-
+ public:
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 3414. service_already_exists has no usable constructors
service_already_exists() : logic_error("service already exists") { }
};
diff --git a/libstdc++-v3/testsuite/experimental/net/execution_context/make_service.cc b/libstdc++-v3/testsuite/experimental/net/execution_context/make_service.cc
index f134add48b5..0898d12927a 100644
--- a/libstdc++-v3/testsuite/experimental/net/execution_context/make_service.cc
+++ b/libstdc++-v3/testsuite/experimental/net/execution_context/make_service.cc
@@ -34,3 +34,6 @@ void test01(net::execution_context& c)
{
net::make_service<S>(c);
}
+
+static_assert(std::is_default_constructible<net::service_already_exists>(),
+ "LWG 3414. service_already_exists has no usable constructors");