Created on 2015-11-14.00:00:00 last changed 81 months ago
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.
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.
History | |||
---|---|---|---|
Date | User | Action | Args |
2018-02-27 00:00:00 | admin | set | messages: + msg6021 |
2018-02-27 00:00:00 | admin | set | status: open -> nad |
2015-11-14 00:00:00 | admin | create |