Created on 2020-03-17.00:00:00 last changed 2 days ago
Proposed resolution:
Change in 12.2.2.9 [over.match.class.deduct] paragraph 1.8 as follows:
- if ei is of array type and xi is a braced-init-list
or string-literal, Ti is an rvalue reference to the declared type of ei, and- if ei is of array type and xi is a string-literal, Ti is an lvalue reference to the const-qualified declared type of ei, and
- ...
Append to the example in 12.2.2.9 [over.match.class.deduct] paragraph 2 as follows:
G g(true, 'a', 1); // OK, deduces G<char, bool>
template<class T, std::size_t N> struct H { T array[N]; }; template<class T, std::size_t N> struct I { volatile T array[N]; }; template<std::size_t N> struct J { unsigned char array[N]; }; H h = { "abc" }; // OK, deduces H<char, 4> (not T = const char) I i = { "def" }; // error: cannot bind reference to volatile-qualified type to a temporary J j = { "ghi" }; // OK, deduces J<4>
Consider:
template<typename T, std::size_t N> struct A { T array[N]; }; A a = { "meow" };
The current wording says in 12.2.2.9 [over.match.class.deduct] bullet 1.8:
- if ei is of array type and xi is a braced-init-list or string-literal, Ti is an rvalue reference to the declared type of ei, and
- ...
This will fail overload resolution, because a string literal (which is an lvalue) does not match a parameter of type T (&&)[N].
History | |||
---|---|---|---|
Date | User | Action | Args |
2023-01-28 21:44:57 | admin | set | status: open -> review |
2023-01-14 22:16:14 | admin | set | messages: + msg7132 |
2020-03-17 00:00:00 | admin | create |