Dan*_*ier 21 c++ compilation functor most-vexing-parse
class foo {
public:
bool operator () (int & i) {
return true;
}
};
int main() {
foo(WhyDoesThisCompile);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当传递WhyDoesThisCompile(没有空格)到仿函数时,程序编译.
为什么是这样?我在clang 4.0.0上测试过它.
Lig*_*ica 30
你没有调用仿函数.
你正在宣布一个foo叫做的人WhyDoesThisCompile.
是的,尽管有括号.
我想你的意思是:
foo()(WhyDoesThisCompile);
// ^^^^^
// temp ^^^^^^^^^^^^^^^^^^^^
// of invocation of op()
// type
// `foo`
Run Code Online (Sandbox Code Playgroud)
......没有.
| 归档时间: |
|
| 查看次数: |
1243 次 |
| 最近记录: |