C++ 编译器错误,带有额外大括号“此处不允许自动”

C++ 编译器错误,带有额外大括号“此处不允许自动”,c++,C++,因此,我的编辑器插入了一对额外的大括号——我很惊讶代码没有编译。谁能解释一下这里发生了什么。这与自动无关-这也不会编译: template <typename T, size_t N> class myarray : public std::array<T, N> { }; int main() { myarray< myarray<unsigned int , 4>, 8> test2d; // Why does using an

因此,我的编辑器插入了一对额外的大括号——我很惊讶代码没有编译。谁能解释一下这里发生了什么。

这与自动无关-这也不会编译:

template <typename T, size_t N>
class myarray : public std::array<T, N>
{
};

int main()
{

   myarray< myarray<unsigned int , 4>, 8> test2d;
   // Why does using an extra pair of braces gives a compile error
   for ((auto &n : test2d)) {
     n.fill(0xdeadbeef); // init a 2D array
   }    
   return 0;
}

额外的括号试图将括号内的内容转换为表达式。

这与自动无关-这也不会编译:

template <typename T, size_t N>
class myarray : public std::array<T, N>
{
};

int main()
{

   myarray< myarray<unsigned int , 4>, 8> test2d;
   // Why does using an extra pair of braces gives a compile error
   for ((auto &n : test2d)) {
     n.fill(0xdeadbeef); // init a 2D array
   }    
   return 0;
}
额外的括号试图将括号内的内容转换为表达式