我在 Stroustrup 的 TCPPPL 中遇到了以下程序:
int main()
{
string from, to;
cin >> from >> to; // get source and target file names
ifstream is {from}; // input stream for file "from"
istream_iterator<string> ii {is}; // input iterator for stream
istream_iterator<string> eos {}; // input sentinel
ofstream os{to}; // output stream for file "to"
ostream_iterator<string> oo {os,"\n"}; // output iterator for stream
vector<string> b {ii,eos}; // b is a vector initialized from input [ii:eos)
sort(b.begin(),b.end()); // sor t the buffer
unique_copy(b.begin(),b.end(),oo);// copy buffer to output, discard //replicated values
return !is.eof() || !os; // return error state (§2.2.1, §38.3)
}
我的问题是最后一行是什么,即return !is.eof() ||!os;
在做什么。我知道如果 main 返回非零值,那么这意味着一个错误,但这里返回的是什么?