次のコンパイラ エラーに驚いています。
template <typename T>
struct A
{
A(T t): t_{t} {}
T t_;
};
struct S
{
};
int main()
{
A<S> s{S{}};
}
エラーは(clangで):
test.cpp:4:16: error: excess elements in struct initializer
A(T t): t_{t} {}
^
test.cpp:15:10: note: in instantiation of member function 'A<S>::A' requested here
A<S> s{S{}};
^
GCC でも同様のエラーが発生します。
式がからt_{t}
構成をコピーしようとすることを期待します。暗黙的に生成されたコピー コンストラクターがあるため、これが問題になることはないと思います。t_
t
S
誰かがここで何が起こっているのか説明できますか?