Date: Wed, 16 Aug 2023 11:59:05 -0400
On Wed, Aug 16, 2023 at 11:39 AM Kang Hewill via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> Hello all C++ experts,
>
> I find it very convenient to allow using-type alias in the requires-clause.
>
> For complex type aliases, simplifying them with using-alias can reduce redundant spelling for subsequent constraint checks on the same type alias.
>
> Take the standard concept indirectly-readable-impl as an example:
>
> 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>&> &&
> common_reference_with<iter_reference_t<In>&&, iter_rvalue_reference_t<In>&&> &&
> common_reference_with<iter_rvalue_reference_t<In>&&, const iter_value_t<In>&>;
>
> we can simplify it to:
>
> 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&>;
> requires common_reference_with<reference&&, rvalue_reference&>;
> requires common_reference_with<rvalue_reference&&, const value_type&>;
> };
>
> Do you think it's worth supporting this using-alias syntax in the requires-clause?
I think the best justification for this change is that it reduces
repetition and thus makes it less likely to cause errors due to
mistyping something. Most of those errors will be compile-time errors,
but it's not unreasonable.
That being said, you used standardese wrong. This is a
requires-expression, not a requires-clause.
<std-proposals_at_[hidden]> wrote:
>
> Hello all C++ experts,
>
> I find it very convenient to allow using-type alias in the requires-clause.
>
> For complex type aliases, simplifying them with using-alias can reduce redundant spelling for subsequent constraint checks on the same type alias.
>
> Take the standard concept indirectly-readable-impl as an example:
>
> 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>&> &&
> common_reference_with<iter_reference_t<In>&&, iter_rvalue_reference_t<In>&&> &&
> common_reference_with<iter_rvalue_reference_t<In>&&, const iter_value_t<In>&>;
>
> we can simplify it to:
>
> 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&>;
> requires common_reference_with<reference&&, rvalue_reference&>;
> requires common_reference_with<rvalue_reference&&, const value_type&>;
> };
>
> Do you think it's worth supporting this using-alias syntax in the requires-clause?
I think the best justification for this change is that it reduces
repetition and thus makes it less likely to cause errors due to
mistyping something. Most of those errors will be compile-time errors,
but it's not unreasonable.
That being said, you used standardese wrong. This is a
requires-expression, not a requires-clause.
Received on 2023-08-16 15:59:17