Skip to content

Instantly share code, notes, and snippets.

@martenlienen
Created December 2, 2015 18:16
Show Gist options
  • Save martenlienen/f2fb81430de3f1bc37ef to your computer and use it in GitHub Desktop.
Save martenlienen/f2fb81430de3f1bc37ef to your computer and use it in GitHub Desktop.
vector casting trickery
#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