diff options
author | Leah Neukirchen <leah@vuxu.org> | 2017-12-05 16:07:34 +0100 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2017-12-05 16:07:34 +0100 |
commit | dff16e900f2dd3e9e257a015d22bec6b73529cc7 (patch) | |
tree | cad4ad955744193d1d40e71558063615638d8b01 | |
parent | 73e28533374104587c3baf42b29ff6094f4d54b9 (diff) | |
download | adventofcode2017-dff16e900f2dd3e9e257a015d22bec6b73529cc7.tar.gz adventofcode2017-dff16e900f2dd3e9e257a015d22bec6b73529cc7.tar.xz adventofcode2017-dff16e900f2dd3e9e257a015d22bec6b73529cc7.zip |
use {} instead of istream_iterator()
-rw-r--r-- | day02.cc | 4 | ||||
-rw-r--r-- | day04.cc | 6 |
2 files changed, 4 insertions, 6 deletions
diff --git a/day02.cc b/day02.cc index ba955ee..d19b454 100644 --- a/day02.cc +++ b/day02.cc @@ -13,9 +13,9 @@ int main() int s1 = 0, s2 = 0; while (getline(cin, line)) { + // slurp it for part 2 istringstream is{line}; - vector<int> v{istream_iterator<int>(is), - istream_iterator<int>()}; // slurp it for part 2 + vector<int> v{istream_iterator<int>(is), {}}; auto [min, max] = minmax_element(begin(v), end(v)); s1 += *max - *min; diff --git a/day04.cc b/day04.cc index 85ae224..7d7d48b 100644 --- a/day04.cc +++ b/day04.cc @@ -34,11 +34,9 @@ main() while (getline(cin, line)) { istringstream is1{line}, is2{line}; - set<string> words{istream_iterator<string>(is1), - istream_iterator<string>()}; + set<string> words{istream_iterator<string>(is1), {}}; anagram::set awords{words.cbegin(), words.cend()}; - size_t wcount = distance(istream_iterator<string>(is2), - istream_iterator<std::string>()); + size_t wcount = distance(istream_iterator<string>(is2), {}); if (words.size() == wcount) p1++; if (awords.size() == wcount) p2++; |