Last active
August 29, 2015 14:10
-
-
Save mtao/ad2cfe409846c0605bb6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <vector> | |
#include <algorithm> | |
#include <iterator> | |
#include <iostream> | |
int main(int argc, char* argv[]) { | |
std::vector<int> indices(1e6); | |
/* | |
std::transform(indices.begin(),indices.end(), indices.begin(), [&indices](int& v) -> int { | |
return std::distance(indices.data(),&v); | |
}); | |
*/ | |
/* | |
std::for_each(indices.begin(),indices.end(), [&indices](int& v) { | |
v = std::distance(indices.data(),&v); | |
}); | |
*/ | |
std::iota(indices.begin(),indices.end(),0); | |
for(auto&& v: indices) { | |
std::cout << v << " "; | |
} | |
std::cout << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment