Title
Parameter type determination in a requirement-parameter-list
Status
drwp
Section
7.5.8.1 [expr.prim.req.general]
Submitter
Daveed Vandevoorde

Created on 2020-01-21.00:00:00 last changed 5 months ago

Messages

Date: 2023-11-07.22:25:49

CWG 2023-06-17

There are arguments in favor of both options. Forwarded to EWG with paper issue 1582.

EWG 2023-11-07

Accept the proposed resolution and forward to CWG for inclusion in C++26.

Date: 2023-11-08.05:03:56

Proposed resolution (approved by CWG 2023-11-07):

Change in 7.5.8.1 [expr.prim.req.general] paragraph 3 as follows:

A requires-expression may introduce local parameters using a parameter-declaration-clause (9.3.4.6 [dcl.fct]). A local parameter of a requires-expression shall not have a default argument. The type of such a parameter is determined as specified for a function parameter in 9.3.4.6 [dcl.fct]. These parameters have no linkage, storage, or lifetime; they are only used as notation for the purpose of defining requirements. The parameter-declaration-clause of a requirement-parameter-list shall not terminate with an ellipsis.
[Example 2:
  template<typename T>
  concept C = requires(T t, ...) {  // error: terminates with an ellipsis
    t;
  };
  template<typename T>
  concept C2 = requires(T p[2]) {
    (decltype(p))nullptr;           // OK, p has type "pointer to T"
  };
end example]
Date: 2024-03-15.00:00:00

[Accepted as a DR at the March, 2024 meeting.]

Consider:

  template<typename T>
    requires requires (T p[10]) { (decltype(p))nullptr; }
  int v = 42;
  auto r = v<int>; // well-formed? 

This example is only well-formed if the type of the parameter p is adjusted to T*, but the provisions in 9.3.4.6 [dcl.fct] paragraph 5 cover function parameters only.

One option is to specify application of the same adjustments as for function parameters. Another option is to specify rules that arguably are more useful in a requires-expression.

History
Date User Action Args
2024-07-20 13:52:34adminsetstatus: dr -> drwp
2024-04-05 21:43:46adminsetstatus: ready -> dr
2024-03-20 14:10:31adminsetstatus: tentatively ready -> ready
2023-12-02 15:54:05adminsetstatus: review -> tentatively ready
2023-11-07 22:25:49adminsetstatus: open -> review
2023-06-20 06:44:53adminsetmessages: + msg7329
2022-03-31 07:31:09adminsetmessages: + msg6784
2020-01-21 00:00:00admincreate