19 template <
typename T,
int N>
23 using ArrayT = std::array<T,N>;
24 using const_iterator =
typename ArrayT::const_iterator;
35 ndarray(
const std::vector<T>& vec) {
36 if (vec.size() != N) {
37 std::stringstream msg;
38 msg <<
"Value vector of wrong size supplied to a " << N <<
" dimensional array";
39 throw RangeError(msg.str());
41 for (
size_t i = 0; i < N; ++i) _val[i] = vec[i];
46 ndarray(
const std::array<T,N> arr) {
70 for (
size_t i = 0; i < N; ++i) _val[i] = T();
74 T& operator[](
size_t i) {
79 const T& operator[](
size_t i)
const {
84 const_iterator begin()
const {
return _val.cbegin(); }
87 const_iterator end()
const {
return _val.cend(); }
Anonymous namespace to limit visibility.