From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [committed 5/5] libstdc++: Constrain net::executor constructors
Date: Fri, 24 Feb 2023 14:28:08 +0000 [thread overview]
Message-ID: <20230224142808.714075-5-jwakely@redhat.com> (raw)
In-Reply-To: <20230224142808.714075-1-jwakely@redhat.com>
Tested x86_64-linux. Pushed to trunk.
-- >8 --
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.
---
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<typename _Executor>
+ 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<typename _Executor>
+ template<typename _Executor,
+ typename = _Require<is_lvalue_reference<_Context_t<_Executor>>>>
executor(_Executor __e)
: _M_target(make_shared<_Tgt1<_Executor>>(std::move(__e)))
{ }
- template<typename _Executor, typename _ProtoAlloc>
+ template<typename _Executor, typename _ProtoAlloc,
+ typename = _Require<is_lvalue_reference<_Context_t<_Executor>>>>
executor(allocator_arg_t, const _ProtoAlloc& __a, _Executor __e)
: _M_target(allocate_shared<_Tgt2<_Executor, _ProtoAlloc>>(__a,
std::move(__e), __a))
--
2.39.2
prev parent reply other threads:[~2023-02-24 14:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-24 14:28 [committed 1/5] libstdc++: Optimize net::ip::address_v4::to_string() Jonathan Wakely
2023-02-24 14:28 ` [committed 2/5] libstdc++: Fix conversion to/from net::ip::address_v4::bytes_type Jonathan Wakely
2023-02-24 14:28 ` [committed 3/5] libstdc++: Fix members of net::ip::network_v4 Jonathan Wakely
2023-02-24 14:28 ` [committed 4/5] libstdc++: Make net::ip::basic_endpoint comparisons constexpr Jonathan Wakely
2023-02-24 14:28 ` Jonathan Wakely [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230224142808.714075-5-jwakely@redhat.com \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).