In C ++ 11, the std::ifstream will accept the std::string parameter as the parameter. A string that along with the copy constructor is std::vector , and this should work:
std::vector<std::string> filenames; std::vector<std::ifstream> files(filenames.begin(), filenames.end());
source share