public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-6328] libstdc++: Constrain net::executor constructors
@ 2023-02-24 14:26 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2023-02-24 14:26 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:8520132bc362d5f915eb1cb20038492e37b3cf88

commit r13-6328-g8520132bc362d5f915eb1cb20038492e37b3cf88
Author: Jonathan Wakely <jwakely@redhat.com>
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<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))

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-24 14:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-24 14:26 [gcc r13-6328] libstdc++: Constrain net::executor constructors Jonathan Wakely

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).