Movatterモバイル変換


[0]ホーム

URL:


This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 119a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025-12-20


2560. Parameter type determination in arequirement-parameter-list

Section:7.5.8.1  [expr.prim.req.general]    Status:CD7    Submitter:Daveed Vandevoorde    Date:2020-01-21    Liaison:EWG

[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 theparameterp is adjusted toT*, but the provisions in9.3.4.6 [dcl.fct] paragraph 5 cover function parametersonly.

One option is to specify application of the same adjustments as forfunction parameters. Another option is to specify rules that arguablyare more useful in arequires-expression.

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

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

Arequires-expression may introduce local parameters usingaparameter-declaration-clause(9.3.4.6 [dcl.fct]). A local parameter ofarequires-expression shall not have a default argument.The type of such a parameter is determined as specified fora function parameter in 9.3.4.6 [dcl.fct]. Theseparameters have no linkage, storage, or lifetime; they are only usedas notation for the purpose of definingrequirements. Theparameter-declaration-clause ofarequirement-parameter-list shall not terminate with anellipsis.
[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 toT"  };
end example]

CWG 2023-06-17

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

EWG 2023-11-07

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




[8]ページ先頭

©2009-2026 Movatter.jp