Skip to content

Instantly share code, notes, and snippets.

@ibab
Created May 21, 2014 13:12
Show Gist options
  • Save ibab/11250ecf97b40d9c3049 to your computer and use it in GitHub Desktop.
Save ibab/11250ecf97b40d9c3049 to your computer and use it in GitHub Desktop.
array2d
#include <vector>
#include <iostream>
#include <array>
#include <algorithm>
template <class T, unsigned I, unsigned J>
using array2d = std::array<std::array<T, J>, I>;
int main(int argc, char *argv[])
{
array2d<double, 10, 10> test{};
test[5][5] = 42;
for (std::size_t i=0; i<test.size(); i++) {
for (std::size_t j=0; j<test[0].size(); j++) {
std::cout << test[i][j] << " ";
}
std::cout << std::endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment