WiS*_*GaN 4 c++ initialization vector c++11
如何std::vector<std::ifstream>从现有的初始化
std::vector<std::string>文件的名称打开?
没有初始化vector,我可以使用它
std::vector<std::string> input_file_names;
// Populate the vector with names of files that needs to open.
// ...
std::vector<std::ifstream> input_files_;
for (auto const & input_file_name : input_file_names) {
input_files_.emplace_back(input_file_name);
}
Run Code Online (Sandbox Code Playgroud)
she*_*heu 14
在c ++ 11中,std::ifstream构造函数将a std::string作为参数.与std::vector复制构造函数一起使用的字符串,这应该有效:
std::vector<std::string> filenames;
std::vector<std::ifstream> files(filenames.begin(), filenames.end());
Run Code Online (Sandbox Code Playgroud)