Skip to content

Instantly share code, notes, and snippets.

@njlr
Created September 7, 2017 10:54
Show Gist options
  • Save njlr/b003eca20efedaa6a51237a843d6fbd0 to your computer and use it in GitHub Desktop.
Save njlr/b003eca20efedaa6a51237a843d6fbd0 to your computer and use it in GitHub Desktop.
template<int D>
struct Vector {
static constexpr unsigned N = D;
  int data[N];
Vector(int fill = 0) {
  for (int i = 0; i < N; ++i) {
  data[i] = fill;
  }
  }
int& operator[] (unsigned const& i) {
 if (N <= i) {
  throw "out of bound";
  }
  return data[i];
  }
 
  // begin, end, etc...
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment