考虑以下代码:
template <typename B>
struct D : B { };
D d{[]{ }};
gcc 12.x 接受它并推断
d
为D</* type of lambda */>
预期的那样。clang 14.x 拒绝它并出现以下错误:
<source>:4:3: error: no viable constructor
or deduction guide for deduction of template arguments of 'D'
D d{[]{ }};
^
<source>:2:8: note: candidate template ignored:
could not match 'D<B>' against '(lambda at <source>:4:5)'
struct D : B { };
^
<source>:2:8: note: candidate function template not viable:
requires 0 arguments, but 1 was provided
哪个编译器在这里表现正确?