阅读背景:

为什么getline()在异常掩码未设置为eofbit时抛出'std: ios_base::failure' ?

来源:互联网 

Consider the following code:

考虑下面的代码:

    ifstream in;
    try {
        in.exceptions ( ifstream::failbit | ifstream::badbit );
        in.open(pConfLocation);
    } catch ( ifstream::failure e ) {
        throw std::runtime_error("Can't open configuration file\n");
    }

    vector<string> lns;
    string s;

    in.clear();
    while ( !in.eof() ){
        getline( in, s );
        boost::algorithm::trim(s);
        lns.push_back( s+='\n');
    }
    i



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: