17.12.2013, 09:55. Просмотров 767. Ответов 1
C++ |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| #include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <string>
using namespace std;
bool contains(std::string word, std::string substring) {
return word.find(substring) != std::string::npos;
}
int main()
{
std::string s = "word1 word2 enother world",
sub = "word";
std::copy(std::istringstream(s), std::istringstream(), std::cout,
std::bind2nd(std::ptr_fun(contains), sub));
return 0;
} |
|
Видел много раз похожий финт, только я так и не понял как он работает (у меня представлен нерабочий вариант).
copy_if должна принимать 3 итератора, 2 на исходный диапазон и 1 для вывода результата, только как это сделать....