Error reporting
To properly replicate the functionality of wc the error in this loop should print to std::cerr rather than std::cout.
/* Loop over all the specified files */ for (auto fileName: files) { std::ifstream file(fileName); if (!file) { std::cout << "Unknown file: " << fileName << "\n"; } else { display(file, fileName, options); } }
As I can see on my test machine:
% wc foo
wc: foo: open: No such file or directory
% wc foo 2> /dev/null
%
Fortunately, it's about the simples fix imaginable. All of three characters.
Strings
Consider std::string_view vs. const std::string&.
From Stack Overflow: How exactly is std::string_view faster than const std::string&?