【发布时间】:2017-11-23 13:19:54
【问题描述】:
我有一个错字(|| 而不是|),并注意到这样的代码在 GCC 中失败并使用 Visual 进行编译。
我知道std::ifstream 的第二个参数是int。所以理论上,bool 必须隐式转换为int。那么为什么会失败呢?
引发错误的示例(我只是使用了一些整数而不是标志)。
#include <fstream>
int main(int argc, char * argv[]) {
std::ifstream("foo", 2 | 3 || 4)
}
【问题讨论】:
标签: c++ language-lawyer ifstream