About the aspect of "template meta-programming". With the idea of being able to compute something at compile-time, I am looking at a way to create the specific variation of the class, instantiate an object of that class and initialize its content (the values) at compile-time.
The specific variation of the class is created at compile-time.
An actual object, an instance of a matrix class and its storage, is not created until run-time.
I have the idea that if I could do that, I could then use "Expression Templates" in order to handle those objects and all this at compile-time.
The first question is:
1) Does that sound irrealistic or am I somehow on a good path?
Then, the problem seems to be the initialization of the object. I thought about passing the values as template parameters:
Code:
template<typename T, unsigned int rows_arg, unsigned int columns_arg, T mat_arg[rows_arg][columns_arg]>
class Matrix{
private:
static const unsigned int rows=rows_arg, columns=columns_arg;
static const T* mat_data = mat_arg;
public:
...
};
int main(){
Matrix<int, 2, 2, {{3, 5 }, {7, 9 }}> m1;
return 0;
};
But it seems this is not correct. So my second question is:
2) Is it possible somehow to pass an array of dimension 2 as a template parameter?
3) If not, is there any other way to initialize the static const member of a template class object?
Thank you for your help.