Created on 2019-01-07.00:00:00 last changed 6 months ago
[ Resolved by paper P2308R1 (Template parameter initialization), adopted in November, 2023. ]
Since non-type template parameters can now have class types, it would seem to make sense to allow a braced-init-list as a template-argument, but the grammar does not permit it.
See also issues 2049 and 2459.
Possible resolution:
The resolution also addresses issue 2049.
Change in 7.3.1 [conv.general] paragraph 3 as follows:
An expression or braced-init-list E can be implicitly converted to a type T if and only if the declaration T t = E; is well-formed, for some invented temporary variable t (9.4 [dcl.init]).
Change in 7.7 [expr.const] paragraph 12 as follows:
A converted constant expression of type T is an expression or braced-init-list, implicitly converted to type T, where the converted expression is a constant expression and the implicit conversion sequence contains only (12.1 [over.pre])
- user-defined conversions,
- ...
Change in 13.3 [temp.names] paragraph 1 as follows:
template-argument: constant-expression type-id id-expression braced-init-list
Change in 13.4.2 [temp.arg.type] paragraph 4 as follows:
template<auto n> struct B { /* ... */ }; B<5> b1; // OK, template parameter type is int B<'a'> b2; // OK, template parameter type is char B<2.5> b3; // OK, template parameter type is double B<void(0)> b4; // error: template parameter type cannot be void template<int i> struct C { /* ... */ }; C<{ 42 }> c1; // OK
History | |||
---|---|---|---|
Date | User | Action | Args |
2024-04-05 21:43:46 | admin | set | status: dr -> drwp |
2024-02-16 23:59:08 | admin | set | status: review -> dr |
2023-09-18 07:29:25 | admin | set | status: drafting -> review |
2019-01-07 00:00:00 | admin | create |