From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id B4DA138515E4; Fri, 24 Feb 2023 14:26:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B4DA138515E4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677248789; bh=hvOQNxrXwJGoVJqGx4mA9m8qqg7un3z7nvagnfevVak=; h=From:To:Subject:Date:From; b=Yyx4CmebmG5mb9WbRyUjMZQjVMWi5WBbqKmfwAGNVhSWPAWVZRGQY/WV5UUydruHB B4cTVRLty/mSqQINFjXci39qNAg0Hhx1Vgu5dA76EtAr5N6t7HHnLp1s/RVOezyD3N 2GaXjAshDxVCx0l92gnJnJBMUQjXEENlfCJ7Qi+0= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r13-6328] libstdc++: Constrain net::executor constructors X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: 97111dccf97d8b4dbf7c1ef11c72827295a72466 X-Git-Newrev: 8520132bc362d5f915eb1cb20038492e37b3cf88 Message-Id: <20230224142629.B4DA138515E4@sourceware.org> Date: Fri, 24 Feb 2023 14:26:29 +0000 (GMT) List-Id: https://gcc.gnu.org/g:8520132bc362d5f915eb1cb20038492e37b3cf88 commit r13-6328-g8520132bc362d5f915eb1cb20038492e37b3cf88 Author: Jonathan Wakely Date: Fri Feb 24 13:03:49 2023 +0000 libstdc++: Constrain net::executor constructors The TS says the arguments to these constructors shall meet the Executor requirements, so it's undefined if they don't. Constraining on a subset of those requirements won't affect valid cases, but prevents the majority of invalid cases from trying to instantiate the constructor. This prevents the non-explicit executor(Executor) constructor being a candidate anywhere that a net::executor could be constructed e.g. comparing ip::tcp::v4() == ip::udp::v4() would try to convert both operands to executor using that constructor, then compare then using operator==(const executor&, const executor&). libstdc++-v3/ChangeLog: * include/experimental/executor (executor): Constrain template constructors. Diff: --- libstdc++-v3/include/experimental/executor | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/experimental/executor b/libstdc++-v3/include/experimental/executor index cd75d99ddb3..1dae8925916 100644 --- a/libstdc++-v3/include/experimental/executor +++ b/libstdc++-v3/include/experimental/executor @@ -1012,6 +1012,9 @@ inline namespace v1 class executor { + template + using _Context_t = decltype(std::declval<_Executor&>().context()); + public: // construct / copy / destroy: @@ -1021,12 +1024,14 @@ inline namespace v1 executor(const executor&) noexcept = default; executor(executor&&) noexcept = default; - template + template>>> executor(_Executor __e) : _M_target(make_shared<_Tgt1<_Executor>>(std::move(__e))) { } - template + template>>> executor(allocator_arg_t, const _ProtoAlloc& __a, _Executor __e) : _M_target(allocate_shared<_Tgt2<_Executor, _ProtoAlloc>>(__a, std::move(__e), __a))