DivisibleBy:@structtype={d:constint;operator():(this,n:int)->bool={returnn%d==0;}}main:()={v:=std::vector(10,2);std::partial_sum(v.cbegin(),v.cend(),v.begin());std::cout<<"Among the numbers: ";std::copy(v.cbegin(),v.cend(),std::ostream_iterator<int>(std::cout," "));std::cout<<'\n';ifstd::all_of(v.cbegin(),v.cend(),:(i:int)i%2==0){std::cout<<"All numbers are even\n";}ifstd::none_of(v.cbegin(),v.cend(),std::bind(std::modulus<>(),std::placeholders::_1,2)){std::cout<<"None of them are odd\n";}ifstd::any_of(v.cbegin(),v.cend(),DivisibleBy(7)){std::cout<<"At least one number is divisible by 7\n";}}
Output
Among the numbers: 2 4 6 8 10 12 14 16 18 20
All numbers are even
None of them are odd
At least one number is divisible by 7