我正在尝试获取auto函数的返回类型.这有效:
auto foo(int bar)
{
return 0;
}
typedef std::result_of<decltype(foo)> foo_t;
Run Code Online (Sandbox Code Playgroud)
好的,这是下一步:static auto在类范围中获取函数的返回类型.这也有效:
struct Foo
{
static auto foo(int bar)
{
return 0;
}
};
typedef std::result_of<decltype(Foo::foo)> foo_t;
Run Code Online (Sandbox Code Playgroud)
但这不起作用:
struct Foo
{
static auto foo(int bar)
{
return 0;
}
typedef std::result_of<decltype(Foo::foo)> foo_t;
};
Run Code Online (Sandbox Code Playgroud)
GCC说"错误:在扣除'auto'之前使用'static auto Foo :: foo(int)'",Clang说"在推定返回类型之前,函数'foo'不能在定义之前使用".为什么?