This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115d. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-10-26
Consider:
struct S { operator int(); }; template<int N> void f(const int (&)[N]); int main() { S s; f<2>({s, s}); // #1 f({s, s}); // #2 }
Since the array element type is not deduced, implicit conversions ought to be permitted in #2 but other implementations disagree. Is there a compelling reason to disallow them?
For comparison:
#include <initializer_list> struct S { operator int(); }; template<typename T> void f(std::initializer_list<T>); int main() { S s; f<int>({s, s}); }
Because T is not deduced, implicit conversions are allowed, and the number of elements in the underlying temporary array is determined from the number of elements in the initializer list. It seems that the intention of issue 1591 was to allow the underlying temporary array to be deduced directly, so the fact that the array bounds are deduced in the case above shouldn't inhibit implicit conversions.
Rationale (November, 2016):
Although there is an argument to be made for the suggested direction, the current rule is simple and easy to explain, so there was no consensus for a change.