C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Allow using type alias in requires-clause

From: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
Date: Wed, 16 Aug 2023 12:07:37 -0400
On Wed, Aug 16, 2023 at 12:00 PM Jason McKesson via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> On Wed, Aug 16, 2023 at 11:56 AM Arthur O'Dwyer via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
> > On Wed, Aug 16, 2023 at 11:39 AM Kang Hewill via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
> >>
> >> template<class In>
> >> concept indirectly-readable-impl =
> >> requires(const In in) {
> >> typename iter_value_t<In>;
> >> typename iter_reference_t<In>;
> >> typename iter_rvalue_reference_t<In>;
> >> { *in } -> same_as<iter_reference_t<In>>;
> >> { ranges::iter_move(in) } -> same_as<iter_rvalue_reference_t<In>>;
> >> } &&
> >> common_reference_with<iter_reference_t<In>&&, iter_value_t<In>&> &&
>
[...]

> >> template<class In>
> >> concept indirectly-readable-impl =
> >> requires(const In in) {
> >> using value_type = typename iter_value_t<In>;
> >> using reference = typename iter_reference_t<In>;
> >> using rvalue_reference = typename iter_rvalue_reference_t<In>;
> >> { *in } -> same_as<reference>;
> >> { ranges::iter_move(in) } -> same_as<rvalue_reference>;
> >> requires common_reference_with<reference&&, value_type&>;
>
[...]

> Plus, the major change you made there doesn't have anything to do with
> aliases — you merely moved the previously-subsumed sub-concepts into the
> requires-expression. That could be done today, if we didn't care about
> subsumption; and it can't be done tomorrow, if we continue to care about
> subsumption. So your example is not only not-very-motivating, it's also
> apples-to-oranges.
>
> It's unclear how this breaks subsumption. Are type aliases meaningful to
> subsumption?
>

No; that's what I mean — the major change here isn't anything to do with
aliases, it's the subsumption-breakage. Hewill is changing a concept of the
form

template<class T>
concept C = requires { stuff; } && C2<T>;

into

template<class T>
concept C = requires { stuff; requires C2<T>; };

The former C subsumes C2. The latter doesn't. And that has nothing at all
to do with type aliases.

–Arthur

Received on 2023-08-16 16:07:50