Created
December 2, 2015 18:16
-
-
Save martenlienen/f2fb81430de3f1bc37ef to your computer and use it in GitHub Desktop.
vector casting trickery
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 <array> | |
#include <iostream> | |
#include <vector> | |
int main() { | |
std::vector<std::array<int, 2>> as{{1, 2}, {3, 4}, {7, -1}}; | |
int* buffer = (int*)as.data(); | |
for (int i = 0; i < as.size() * 2; i++) { | |
std::cout << buffer[i] << std::endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment