标签: alias-declaration

函数类型别名声明中是否允许嵌套括号?

以下代码可以使用 gcc-13 和 clang-16 编译,但 MSVC 报告多个错误

using foo_type = void ((((int, const char*))));   // (1)
// Compiler messages for line (1):
//    clang-16: ok.
//    gcc-13:   ok.
//    MSVC-v19: error C2062: type 'int' unexpected.


foo_type foo;

int main()
{
    foo(5, "Hello");
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

问题是:谁是对的?标准是否允许alias-declaration函数类型在参数列表周围有多个嵌套括号,就像上面的示例中所尝试的那样?

c++ language-lawyer compiler-specific c++17 alias-declaration

7
推荐指数
1
解决办法
178
查看次数