当我测试C++ STL功能时,我有一个奇怪的问题。如果我取消注释该行(eee),则我的while循环不会退出。
我在64位Windows下使用vs2015。做这个stl操作符>>函数是否会发生魔法?
int i = 0;
istream& mystream = data.getline(mycharstr,128);
size_t mycount = data.gcount();
string str(mycharstr,mycharstr+mycount);
istringstream myinput(str);
WORD myfunclist[9] = {0};
for_each(myfunclist,myfunclist+9, [](WORD& i){ i = UINT_MAX;});
CALLEESET callee_set;
callee_set.clear();
bool failbit = myinput.fail();
bool eof = myinput.eof();
while (!failbit && !eof)
{
int eee = myinput.peek();
if (EOF == eee) break;
//if (eee) // if i uncomment this line ,the failbit and eof will always be false,so the loop will never exit.
{
myinput >> myfunclist[i++];
}
//else break;
failbit = myinput.fail();
eof = myinput.eof();
cout << myinput.rdstate() << endl;
}
@Christophe - 这怎么可能是完全相同的副本?这看起来很不同,因为使用了'偷看'和'失败'。此外,问题是关于与EOF无关的if语句。 – 4386427
@ 4386427你是对的,它不是一个确切的副本。我重新打开了 – Christophe
丹尼斯,你能解释一下它与标准模板库(STL)的关系吗? – Christophe