Skip to content

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

@jensmaurer

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.

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