Created
September 7, 2017 10:54
-
-
Save njlr/b003eca20efedaa6a51237a843d6fbd0 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
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