struct Matrix(int row, int col){ }
pure M inverse(M)(const ref M m){ }
The reason mis refdue to performance. Obviously, I don't want large matrices to be copied every time the opposite is required, and so far this has worked fine.
But this has become a problem in situations where the opposite is required at compile time:
mixin template A(){
alias Matrix!(3, 3) Matrix3x3;
static Matrix3x3 computeSomeMatrix(){ }
immutable Matrix3x3 _m = computeSomeMatrix();
immutable Matrix3x3 _m_1 = inverse(computeSomeMatrix());
}
To fix the error, I need to change mto non-ref, but this means that the matrices will be copied every time it is called inverse(). What should I do?
Arlen source
share