Closed huixie90 closed 2 years ago
This is intentional, although not all the authors of P2300 agree about this. The intent is that all receivers support exception_ptr
as an error type. A function such as the following:
template <receiver_of<int> R>
void tag_invoke(connect_t, my_sender const&, R&&);
... is constrained to accept a receiver that accepts an int
as a value and an exception_ptr
as an error. If a function is going to send another kind of error -- say, error_code
-- it would look like this:
template <receiver_of<int> R>
requires receiver<R, error_code>
void tag_invoke(connect_t, my_sender const&, R&&);
That receiver type must accept both exception_ptr
and error_code
as errors.
The
receiver
concept gives the flexibility to specify the error type withexpcetion_ptr
being the defaultBut the
receiver_of
concept forces to useexpcetion_ptr
as the error typeIs this by design and what is the rationale behind this inconsistency?