Created
September 15, 2018 05:05
-
-
Save mochow13/b937f9067861c54cfb3d0d732784a138 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
std::vector<int> collection={1,2,0,5,0,3,4}; | |
int counter=0; | |
// notice that we are capturing counter by reference | |
std::generate(begin(collection), end(collection), [&]() { | |
return counter++; | |
}); | |
// collection gets replaced by values starting from 0 | |
// modified collection = {0,1,2,3,4,5,6} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment