-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvs08.cpp
More file actions
31 lines (28 loc) · 798 Bytes
/
vs08.cpp
File metadata and controls
31 lines (28 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <algorithm>
#include <iostream>
#include <set>
#include <string>
#include <vector>
void f() {
std::vector<std::string> names{"Tom", "Tim", "Bart", "Harry"};
auto end = names.end();
auto i = find_if(names.begin(), end,
[](const auto& name) { return name.size() > 3; });
if (i == end)
std::cout << "Only short names.\n";
else
std::cout << "First long name: " << *i << ".\n";
}
void g() {
std::vector<std::string> names{"Tom", "Tim", "Bart", "Harry"};
std::set<std::string> blocklist{"Bart"};
if (any_of(names.begin(), names.end(),
[&](const auto& name) { return blocklist.count(name) > 0; }))
std::cout << "Blocked name found!\n";
else
std::cout << "All names are good to go!\n";
}
int main(int, char**) {
f();
g();
}