是否可以使用auto关键字和多字类型声明变量?
如果不是,为什么不呢?
例如
auto foo = unsigned int{0};
提供以下编译器输出
Clang:
error: expected '(' for function-style cast or type construction
GCC:
error: expected primary-expression before 'unsigned'
您可以使用以下任何一种:
auto foo = 0U;
auto foo = (unsigned int)0;
auto foo = static_cast<unsigned int>(0);