Skip to content

Commit 4b64ebb

Browse files
committed
P3557R3 High-Quality Sender Diagnostics with Constexpr Exceptions (Part 1 - up to [exec.snd.expos]p39)
1 parent 0096f88 commit 4b64ebb

File tree

1 file changed

+82
-50
lines changed

1 file changed

+82
-50
lines changed

source/exec.tex

Lines changed: 82 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,9 @@
372372
The type of the receiver does not affect
373373
an asynchronous operation's completion signatures,
374374
only the type of the receiver's environment.
375+
A \defnadj{non-dependent}{sender} is a sender type
376+
whose completion signatures are knowable
377+
independent of an execution environment.
375378

376379
\pnum
377380
A sender algorithm is a function that takes and/or returns a sender.
@@ -528,23 +531,18 @@
528531
template<class Sndr>
529532
concept @\libconcept{sender}@ = @\seebelow@;
530533

531-
template<class Sndr, class Env = env<>>
534+
template<class Sndr, class Env>
532535
concept @\libconcept{sender_in}@ = @\seebelow@;
533536

537+
template<class Sndr>
538+
concept @\libconcept{dependent_sender}@ = @\seebelow@;
539+
534540
template<class Sndr, class Rcvr>
535541
concept @\libconcept{sender_to}@ = @\seebelow@;
536542

537543
template<class... Ts>
538544
struct @\exposidnc{type-list}@; // \expos
539545

540-
// \ref{exec.getcomplsigs}, completion signatures
541-
struct get_completion_signatures_t;
542-
inline constexpr get_completion_signatures_t get_completion_signatures {};
543-
544-
template<class Sndr, class Env = env<>>
545-
requires @\libconcept{sender_in}@<Sndr, Env>
546-
using completion_signatures_of_t = @\exposid{call-result-t}@<get_completion_signatures_t, Sndr, Env>;
547-
548546
template<class... Ts>
549547
using @\exposidnc{decayed-tuple}@ = tuple<decay_t<Ts>...>; // \expos
550548

@@ -655,7 +653,7 @@
655653
inline constexpr stopped_as_error_t @\libglobal{stopped_as_error}@{};
656654

657655
// \ref{exec.util}, sender and receiver utilities
658-
// \ref{exec.util.cmplsig}
656+
// \ref{exec.util.cmplsig}, completion signatures
659657
template<class Fn>
660658
concept @\exposconceptnc{completion-signature}@ = @\seebelownc@; // \expos
661659

@@ -665,27 +663,15 @@
665663
template<class Sigs>
666664
concept @\exposconceptnc{valid-completion-signatures}@ = @\seebelownc@; // \expos
667665

668-
// \ref{exec.util.cmplsig.trans}
669-
template<
670-
@\exposconcept{valid-completion-signatures}@ InputSignatures,
671-
@\exposconcept{valid-completion-signatures}@ AdditionalSignatures = completion_signatures<>,
672-
template<class...> class SetValue = @\seebelow@,
673-
template<class> class SetError = @\seebelow@,
674-
@\exposconcept{valid-completion-signatures}@ SetStopped = completion_signatures<set_stopped_t()>>
675-
using transform_completion_signatures = completion_signatures<@\seebelow@>;
666+
struct dependent_sender_error : exception {};
676667

677-
template<
678-
@\libconcept{sender}@ Sndr,
679-
class Env = env<>,
680-
@\exposconcept{valid-completion-signatures}@ AdditionalSignatures = completion_signatures<>,
681-
template<class...> class SetValue = @\seebelow@,
682-
template<class> class SetError = @\seebelow@,
683-
@\exposconcept{valid-completion-signatures}@ SetStopped = completion_signatures<set_stopped_t()>>
684-
requires @\libconcept{sender_in}@<Sndr, Env>
685-
using transform_completion_signatures_of =
686-
transform_completion_signatures<
687-
completion_signatures_of_t<Sndr, Env>,
688-
AdditionalSignatures, SetValue, SetError, SetStopped>;
668+
// \ref{exec.getcomplsigs}
669+
template<class Sndr, class... Env>
670+
consteval auto get_completion_signatures() -> @\exposconcept{valid-completion-signatures}@ auto;
671+
672+
template<class Sndr, class... Env>
673+
requires @\libconcept{sender_in}@<Sndr, Env...>
674+
using completion_signatures_of_t = decltype(get_completion_signatures<Sndr, Env...>());
689675

690676
// \ref{exec.run.loop}, run_loop
691677
class run_loop;
@@ -733,18 +719,22 @@
733719
\end{itemize}
734720

735721
\pnum
736-
For types \tcode{Sndr} and \tcode{Env},
737-
\tcode{\exposid{single-sender-value-type}<Sndr, Env>} is an alias for:
722+
For type \tcode{Sndr} and pack of types \tcode{Env},
723+
let \tcode{CS} be \tcode{completion_signatures_of_t<Sndr, Env...>}.
724+
Then \tcode{\exposid{single-sender-value-type}<Sndr, Env>} is ill-formed
725+
if \tcode{CS} is ill-formed or
726+
if \tcode{sizeof...(Env) > 1} is \tcode{true};
727+
otherwise, it is an alias for:
738728
\begin{itemize}
739729
\item
740-
\tcode{value_types_of_t<Sndr, Env, decay_t, type_identity_t>}
730+
\tcode{\exposid{gather-signatures}<set_value_t, CS, decay_t, type_identity_t>}
741731
if that type is well-formed,
742732
\item
743733
Otherwise, \tcode{void}
744-
if \tcode{value_types_of_t<Sndr, Env, tuple, variant>} is
734+
if \tcode{\exposid{gather-signatures}<set_value_t, CS, tuple, variant>} is
745735
\tcode{variant<tuple<>>} or \tcode{vari\-ant<>},
746736
\item
747-
Otherwise, \tcode{value_types_of_t<Sndr, Env, \exposid{decayed-tuple}, type_identity_t>}
737+
Otherwise, \tcode{\exposid{gather-signatures}<set_value_t, CS, \exposid{decayed-tuple}, type_identity_t>}
748738
if that type is well-formed,
749739
\item
750740
Otherwise, \tcode{\exposid{single-sender-value-type}<Sndr, Env>} is ill-formed.
@@ -762,6 +752,11 @@
762752
}
763753
\end{codeblock}
764754

755+
\pnum
756+
A type satisfies and models the exposition-only concept
757+
\exposconcept{valid-completion-signatures} if
758+
it is a specialization of the \tcode{completion_signatures} class template.
759+
765760
\rSec1[exec.queries]{Queries}
766761

767762
\rSec2[exec.fwd.env]{\tcode{forwarding_query}}
@@ -1251,20 +1246,35 @@
12511246
a set of completion operations
12521247
whose first argument is a subexpression equal to \tcode{rcvr}.
12531248
Let \tcode{Sigs} be a pack of completion signatures corresponding to
1254-
this set of completion operations.
1255-
Then the type of the expression \tcode{get_completion_signatures(sndr, env)} is
1249+
this set of completion operations, and
1250+
let \tcode{CS} be
1251+
the type of the expression \tcode{get_completion_signatures(Sndr, Env)()}.
1252+
Then \tcode{CS} is
12561253
a specialization of
12571254
the class template \tcode{completion_signatures}\iref{exec.util.cmplsig},
12581255
the set of whose template arguments is \tcode{Sigs}.
1256+
If none of the types in \tcode{Sigs} are dependent on the type \tcode{Env}, then
1257+
the expression \tcode{get_completion_signatures<Sndr>()} is well-formed and
1258+
its type is \tcode{CS}.
12591259
If a user-provided implementation of the algorithm
1260-
that produced \tcode{sndr} is selected instead of the default,
1261-
any completion signature
1260+
that produced \tcode{sndr} is selected instead of the default:
1261+
1262+
\begin{itemize}
1263+
\item
1264+
Any completion signature
12621265
that is in the set of types
12631266
denoted by \tcode{completion_signatures_of_t<Sndr, Env>} and
12641267
that is not part of \tcode{Sigs} shall correspond to
12651268
error or stopped completion operations,
12661269
unless otherwise specified.
12671270

1271+
\item
1272+
If none of the types in \tcode{Sigs} are dependent on the type \tcode{Env}, then
1273+
\tcode{completion_signatures_of_t<Sndr>} and
1274+
\tcode{completion_signatures_of_t<Sndr, Env>}
1275+
shall denote the same type.
1276+
\end{itemize}
1277+
12681278
\rSec2[exec.snd.expos]{Exposition-only entities}
12691279

12701280
\pnum
@@ -1279,6 +1289,9 @@
12791289
the expression \tcode{\exposid{FWD-ENV}(env).query(q, as...)} is ill-formed
12801290
if \tcode{forwarding_query(q)} is \tcode{false};
12811291
otherwise, it is expression-equivalent to \tcode{env.query(q, as...)}.
1292+
%%FIXME: Where did FWD-ENV-T come from?
1293+
The type \tcode{\exposid{FWD-ENV-T}(Env)} is
1294+
\tcode{decltype(\exposid{FWD-ENV}(declval<Env>()))}.
12821295

12831296
\pnum
12841297
For a query object \tcode{q} and \tcode{a} subexpression \tcode{v},
@@ -1568,6 +1581,16 @@
15681581
otherwise, \tcode{false}.
15691582
\end{itemdescr}
15701583

1584+
\pnum
1585+
Let \exposconcept{valid-specialization} be the following concept:
1586+
\begin{codeblock}
1587+
namespace std::execution {
1588+
template<template<class...> class T, class... Args>
1589+
concept @\defexposconceptnc{valid-specialization}@ = // \expos
1590+
requires { typename T<Args...>; };
1591+
}
1592+
\end{codeblock}
1593+
15711594
\begin{itemdecl}
15721595
template<class Tag, class Data = @\seebelow@, class... Child>
15731596
constexpr auto @\exposid{make-sender}@(Tag tag, Data&& data, Child&&... child);
@@ -1581,6 +1604,19 @@
15811604
\item \tcode{\libconcept{semiregular}<Tag>}
15821605
\item \tcode{\exposconcept{movable-value}<Data>}
15831606
\item \tcode{(\libconcept{sender}<Child> \&\& ...)}
1607+
\item%
1608+
\tcode{\libconcept{dependent_sender}<Sndr> || \libconcept{sender_in}<Sndr>},
1609+
where \tcode{Sndr} is \tcode{\exposid{basic-sender}<Tag, Data, Child...>}
1610+
as defined below.
1611+
1612+
%%FIXME: OK to have \recommended inside an itemized list like this?
1613+
\pnum
1614+
\recommended
1615+
If evaluation of \tcode{\libconcept{sender_in}<Sndr>} results in
1616+
an uncaught exception from
1617+
the evaluation of \tcode{get_completion_signatures<Sndr>()},
1618+
the implementation should include information about that exception in
1619+
the resulting diagnostic.
15841620
\end{itemize}
15851621

15861622
\pnum
@@ -1597,16 +1633,15 @@
15971633
concept @\defexposconceptnc{completion-tag}@ = // \expos
15981634
@\libconcept{same_as}@<Tag, set_value_t> || @\libconcept{same_as}@<Tag, set_error_t> || @\libconcept{same_as}@<Tag, set_stopped_t>;
15991635

1600-
template<template<class...> class T, class... Args>
1601-
concept @\defexposconceptnc{valid-specialization}@ = // \expos
1602-
requires { typename T<Args...>; };
1603-
16041636
struct @\exposidnc{default-impls}@ { // \expos
16051637
static constexpr auto @\exposidnc{get-attrs}@ = @\seebelownc@; // \expos
16061638
static constexpr auto @\exposidnc{get-env}@ = @\seebelownc@; // \expos
16071639
static constexpr auto @\exposidnc{get-state}@ = @\seebelownc@; // \expos
16081640
static constexpr auto @\exposidnc{start}@ = @\seebelownc@; // \expos
16091641
static constexpr auto @\exposidnc{complete}@ = @\seebelownc@; // \expos
1642+
1643+
template<class Sndr, class... Env>
1644+
static consteval void @\exposidnc{check-types}@(); // \expos
16101645
};
16111646

16121647
template<class Tag>
@@ -1621,6 +1656,9 @@
16211656
decltype(@\exposid{impls-for}@<tag_of_t<Sndr>>::@\exposid{get-env}@), Index,
16221657
@\exposid{state-type}@<Sndr, Rcvr>&, const Rcvr&>;
16231658

1659+
template<class Sndr>
1660+
using @\exposidnc{data-type}@ = decltype(declval<Sndr>().template @\exposidnc{get}@<1>()); // \expos
1661+
16241662
template<class Sndr, size_t I = 0>
16251663
using @\exposidnc{child-type}@ = decltype(declval<Sndr>().template @\exposidnc{get}@<I+2>()); // \expos
16261664

@@ -1696,9 +1734,6 @@
16961734
}
16971735
};
16981736

1699-
template<class Sndr, class Env>
1700-
using @\exposidnc{completion-signatures-for}@ = @\seebelownc@; // \expos
1701-
17021737
template<class Tag, class Data, class... Child>
17031738
struct @\exposidnc{basic-sender}@ : @\exposidnc{product-type}@<Tag, Data, Child...> { // \expos
17041739
using sender_concept = sender_t;
@@ -1716,10 +1751,7 @@
17161751
}
17171752

17181753
template<@\exposconcept{decays-to}@<@\exposid{basic-sender}@> Self, class Env>
1719-
auto get_completion_signatures(this Self&& self, Env&& env) noexcept
1720-
-> @\exposid{completion-signatures-for}@<Self, Env> {
1721-
return {};
1722-
}
1754+
static constexpr auto get_completion_signatures();
17231755
};
17241756
}
17251757
\end{codeblock}

0 commit comments

Comments
 (0)