diff --git a/m.cpp b/m.cpp new file mode 100644 index 0000000..b5f7309 --- /dev/null +++ b/m.cpp @@ -0,0 +1,64 @@ +template struct Matrix; + +template +struct Matrix { + typedef T GenericDimType[FirstDim]; + + GenericDimType data; + inline T& operator[](unsigned i) { return data[i]; } +}; + +template +struct Matrix { + typedef typename Matrix::GenericDimType FirstDimType; + typedef FirstDimType GenericDimType[FirstDim]; + + GenericDimType data; + inline FirstDimType& operator[](unsigned i) { return data[i]; } +}; + + + + + + + + + +#include + +int main() { + Matrix m; + + int cnt = 0; + for (size_t i = 0; i < 2; ++i) { + for (size_t j = 0; j < 3; ++j) { + for (size_t h = 0; h < 4; ++h) { + m[i][j][h] = cnt++; + } + } + } + + std::cout << "Data in matrix:\n"; + for (size_t i = 0; i < 2; ++i) { + for (size_t j = 0; j < 3; ++j) { + for (size_t h = 0; h < 4; ++h) { + std::cout << m[i][j][h] << ' '; + } + std::cout << '\n'; + } + std::cout << "ENDDIM\n"; + } + + std::cout << "Addresses in matrix:\n"; + for (size_t i = 0; i < 2; ++i) { + for (size_t j = 0; j < 3; ++j) { + for (size_t h = 0; h < 4; ++h) { + std::cout << &m[i][j][h] << ' '; + } + std::cout << '\n'; + } + std::cout << "ENDDIM\n"; + } + return 0; +} \ No newline at end of file