Created
November 29, 2012 21:32
-
-
Save audioplastic/4172051 to your computer and use it in GitHub Desktop.
Test gist showing some C++11 niceness
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 <iostream> | |
#include <vector> | |
using namespace std; | |
int main () | |
{ | |
vector<int> v{12,324,45,65,787,9}; //Uniform initialization | |
cout << "In vector: "; | |
for (auto val : v) {cout << val << ", ";} //Range based for | |
int m = 5; | |
cout<< "there are " | |
<< count_if(v.begin(), v.end(), [m](int i){return i%m == 0;}) //lambdas | |
<< " multiples of " << m << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment