Created
January 29, 2018 12:23
-
-
Save xfbs/37f71bf10494170bad1b6f37da332154 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <range/v3/all.hpp> | |
#include <vector> | |
#include <array> | |
#include <iostream> | |
using std::cout; | |
using std::endl; | |
using namespace ranges; | |
auto is_six = [](int i) -> bool { return i == 6; }; | |
auto doub = [](int i) -> int { return 2 * i; }; | |
int main() { | |
std::vector<int> v { 6, 2, 3, 4, 5, 6 }; | |
auto c = count_if( v, is_six ); | |
cout << "count-sixes: " << c << endl; | |
auto s = accumulate( v, 0 ); | |
cout << "sum-vetor: " << s << endl; | |
auto e = find_if( view::ints(1) | view::transform(doub), is_six ); | |
cout << "find-six: " << *e.get_unsafe() << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment