ARTICLE AD BOX
Suppose I have a C-style matrix of elements
typedef struct _RAW_DATA{ int a; int b; }RAW_DATA;inside a templated class, that defines the size of the matrix:
template<size_t TDim> struct ProcessedData{ typedef RAW_DATA INPUT_TYPE[TDim][TDim]; };In the aforementioned class, I also need to have 2-dimentional matrix of the same size, that contains processed data for each element of the INPUT_TYPE, but some elements are need to be const:
template<size_t TDim> struct ProcessedData{ ... struct ProcessedElem{ const int a1; const int a2; const int b1; const int b2; int otherValue1; int otherValue2; ProcessedElem(const RAW_DATA &RawData) : ... /*do member initialization*/ {} }; ProcessedElem prcessedData[TDim][TDim] };In the constructor of ProcessedData, I receive the input-matrix:
template<size_t TDim> struct ProcessedData{ ... ProcessedData(const INPUT_TYPE &Input) : prcessedData{/*somehow forward each element of Input to the corresponding element*/} {} };I am on a very tight memory budget, also tricks like std::array or std::arrays are out of the question, i would really like to keep it as simple as possible. I have access to C++20 features, but if a solution requires later standards, I could look into it if i can access those standards.
