The compilers (GCC and Clang) are giving an error when using the curly braces init syntax with designated initializers when initializing a struct template instance.
Here:
template <class T>
struct Foo
{
const T value;
};
int main( )
{
Foo foo { .value = 5 }; // compiles
// Foo foo { .value = { 5 } }; // does not compile
// Foo foo { .value { 5 } }; // does not compile
}
The error message:
<source>: In function 'int main()':
<source>:11:30: error: class template argument deduction failed:
11 | Foo foo { .value = { 5 } };
|
What’s causing this? Isn’t list-initialization allowed in this context? Or something else is the root cause?
1