• Source
    1. #include <iostream>
    2. #include <algorithm>
    3. #include <vector>
    4.  
    5. #define all(a) (a).begin(),(a).end()
    6.  
    7. using namespace std;
    8.  
    9. int main() {
    10. auto v1 = {1, 1, 1, 1, 1};
    11. auto v2 = {1, 1, 1, 2, 1};
    12. vector<vector<int>> v3 = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
    13. vector<vector<int>> v4 = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9, 0}};
    14.  
    15. cout << all_of(all(v1), [](int i) -> bool {return i == 1;}) << endl;
    16. cout << all_of(all(v1), [](int i){return i == 1;}) << endl;
    17. cout << all_of(all(v2), [](int i){return i == 1;}) << endl;
    18. cout << all_of(all(v3), [](vector<int> v){return v.size() == 3;}) << endl;
    19. cout << all_of(all(v4), [](vector<int> v){return v.size() == 3;}) << endl;
    20. }