forked from Mooophy/Cpp-Primer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex10_22.cpp
More file actions
32 lines (27 loc) · 697 Bytes
/
ex10_22.cpp
File metadata and controls
32 lines (27 loc) · 697 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
32
//
// ex10_22.cpp
// Exercise 10.22
//
// Created by pezy on 12/11/14.
// Copyright (c) 2014 pezy. All rights reserved.
//
// @Brief Rewrite the program to count words of size 6 or less using
// functions in place of the lambdas.
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using std::string;
using namespace std::placeholders;
bool isBiggerThan6(const string &s, string::size_type sz)
{
return s.size() > sz;
}
int main()
{
std::vector<string> authors{"Mooophy", "pezy", "Queequeg90", "shbling", "evan617"};
std::cout << count_if(authors.cbegin(), authors.cend(), bind(isBiggerThan6, _1, 6));
}
// @Out
// 4