本文整理汇总了C++中iter::filterfalse方法的典型用法代码示例。如果您正苦于以下问题:C++ iter::filterfalse方法的具体用法?C++ iter::filterfalse怎么用?C++ iter::filterfalse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iter
的用法示例。
在下文中一共展示了iter::filterfalse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
std::vector<int> vec{1, 5, 6, 7, 2, 3, 8, 3, 2, 1};
std::cout << "Greater than 4 (function pointer)\n";
for (auto i : filterfalse(greater_than_four, vec)) {
std::cout << i << '\n';
}
std::cout << "Less than 4 (lambda)\n";
for (auto i : filterfalse([] (const int i) { return i < 4; }, vec)) {
std::cout << i << '\n';
}
LessThanValue lv(4);
std::cout << "Less than 4 (callable object)\n";
for (auto i : filterfalse(lv, vec)) {
std::cout << i << '\n';
}
return 0;
}
示例2: main
int main() {
std::vector<int> vec{1, 5, 6, 7, 2, 3, 8, 3, 2, 1};
std::cout << "Greater than 4 (function pointer)\n";
for (auto i : filterfalse(greater_than_four, vec)) {
std::cout << i << '\n';
}
std::cout << "Less than 4 (lambda)\n";
for (auto i : filterfalse([] (const int i) { return i < 4; }, vec)) {
std::cout << i << '\n';
}
LessThanValue lv(4);
std::cout << "Less than 4 (callable object)\n";
for (auto i : filterfalse(lv, vec)) {
std::cout << i << '\n';
}
std::cout << "zero ints filter(vec2)\n";
std::vector<int> vec2 {0, 1, 2, 0, 3, 0, 0, 0, 4, 5, 0};
for (auto i : filterfalse(vec2)) {
std::cout << i << '\n';
}
std::cout << "Constness tests\n";
const std::vector<int> cvec(vec);
for (auto i : filterfalse(greater_than_four, cvec)) {
std::cout << i << '\n';
}
for (auto i : filterfalse([] (const int & i) { return i < 4; }, cvec)) {
std::cout << i << '\n';
}
return 0;
}