Skip to content

CWG2565 Invalid types in the parameter-declaration-clause of a requires-expression #1695

Description

@jensmaurer

These two examples are very similar, but the second one is ill-formed per the wording despite implementations accepting it due to user demand:

  template <typename T>
  concept C = requires (typename T::type x) {
    x + 1;
  };

  static_assert(!C<int>);

vs.

  template <typename T>
  constexpr bool b = requires (T::type x) { x + 1; };

  static_assert(!b<int>);  // de-jure ill-formed, but widely accepted by implementations

In order to make the second case well-formed, the user needs to write a nested requires that checks for the presence of T::type first.

See CWG2565 for details.

Activity

  1. erichkeane commented on Mar 18, 2024

    @erichkeane
    Collaborator

    This was discussed during the Morning AM session in Tokyo, the following poll was taken:

    CWG2565 EWG agrees that this is an issue worth considering, but would like to see a paper to propose a change.

    SF F N A SA
    1 17 7 1 0

    Result: Consensus

    Paper author not identified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    EWGEvolutionpaper neededAn issue needs a paper to describe its solution

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions