????#include <cerrno>
????#include <cstdio>
????#include <cstdlib>
????#include <fstream>
????#include <iostream>
????#include <numeric>
????#include <unordered_map>
????#include <string>
????#include <vector>
????using std::accumulate;
????using std::cerr;
????using std::cout;
????using std::endl;
????using std::ifstream;
????using std::make_pair;
????using std::pair;
????using std::strerror;
????using std::string;
????using std::unordered_map;
????using std::vector;
????int word_count(const char *const file) noexcept(false);
????int main(int argc?? char *argv[]) {
????vector< pair<string?? int> > counts {};
????for (auto i = 1; i < argc; i += 1) {
????try {
????counts.push_back(make_pair(argv[i]?? word_count(argv[i])));
????} catch (const string& e) {
????cerr << e << endl;
????counts.push_back(make_pair(argv[i]?? -1));
????}
????}
????for (auto& result : counts) {
????cout << result.first << ": " << result.second << " words" << endl;
????}
????return 0;
????}
????int
????word_count(const char *const file) noexcept(false) {
????errno = 0;
????ifstream fp(file);
????{
????// Does fp.fail() preserve errno?
????int save_errno = errno;
????if (fp.fail()) {
????throw("Cannot open '" + string(file) + "': " + strerror(save_errno));
????}
????}
????unordered_map<string?? int> word_count {};
????string word;
????while (fp >> word) {
????word_count[word] += 1;
????}
????fp.close();
????return accumulate(
????word_count.cbegin()??
????word_count.cend()??
????0??
????[](int sum?? auto& el) { return sum += el.second; }
????);
????}
????20 ?д??????? #include ?? using ??????????????е??????????? using namespace std?????????????? std::… ???????????????????????С?
?????????????????п??ü?????????????????????????????????檔
???????????????????????????????????autovivification????
????unordered_map<string?? int> word_count {};
????string word;
????while (fp >> word) {
????word_count[word] += 1;
????}
???????????????? lambda ??????
????return accumulate(
????word_count.cbegin()??
????word_count.cend()??
????0??
????[](int sum?? auto& el) { return sum += el.second; }
????);
??????????accumulate ??????????????? 0????????????????????????????????????????????word_count???????????
?????????????ò??????????????Щ?????????????????? Microsoft Visual C++ 2015 RC ??????????????????????????????????·????
????????????
???????????ж??????????? boost libraries ????????????????????????????????????????????????? Perl ?? CPAN ?????????????д?????κε?????????е????????????????
???????磬??????????????????????????????? Excel ?????????????? Excel ??????????????? clang??g++ ?? cl ???????????????????????
?????????????л??????????????????????????Щ????????????????????????????????????д C++ ???????????????
????????????????????????????????о??????