以下代码不能使用clang++ 3.8.0和g++ 6.3.0编译(编译器标志为-std=c++11 -Wall -Wextra -Werror -pedantic-errors
):
int main()
{
int* a = int*{}; // doesn't compile
// ^^^^ can't be parsed as a type
(void)a;
using PInt = int*;
PInt b = PInt{}; // compiles successfully
// ^^^^ is parsed as a type
(void)b;
}
这是一种强制int*{}
编译器在此处以正确方式解释的方法(typedef
ing ofint*
是其中一种方式)?