개요
예제
- 코드
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;
int main() {
auto func = [](vector<int> v, auto f) {
cout << all_of(v.cbegin(), v.cend(), f) << endl;
cout << any_of(v.cbegin(), v.cend(), f) << endl;
cout << none_of(v.cbegin(), v.cend(), f) << endl;
};
func({}, [](int i) { return true; });
cout << "------ 1" << endl;
func({1, 2, 3}, [](int i) { return i > 0 ? true : false; });
cout << "------ 2" << endl;
func({1, 2, 3}, [](int i) { return i < 0 ? true : false; });
cout << "------ 3" << endl;
func({1, 2, 3}, [](int i) { return i > 2 ? true : false; });
return EXIT_SUCCESS;
}
- 실행 결과
1
0
1
------ 1
1
1
0
------ 2
0
0
1
------ 3
0
1
0