im currently writing a template matrix class, and i got the following error message when compiling my code:
error: template instantiation depth exceeds maximum of 500 instantiating ‘D3::Matrix<type, 4u>::Matrix(type) [with type = long double]’,
possibly from virtual table generation (use -ftemplate-depth-NN to increase the maximum)
What causes the error are the constructors, operator=, and other methods which uses instances of Matrix class with a modified dim parameter (in my case dim-1 is causing the compiler to recursively create instances of my Matrix class)
So basically i want to be able to easily construct a matrix of another matrix that's either one dimension smaller or larger (by removing last row/column or adding one "0 0 0 0...1" row/column) and i want to be able to use matrices of a lower dimension like shown in the void adjoint method.
Is there any way to prevent the compiler from recursively creating 'infinite' instances of the class? Would be great if it's possible to drop some of the classes methods in case the compiler created the class recursively. If i'd be able to drop all of the methods that make use of "Matrix<type, dim-1>" in case the instance was created recursively, the compiler would not create another instance, preventing this error.
Is there any way to do this or are there other solutions to my problem?
What you are saying is that you want to create a template that allows you to create matrices with incompatible behavior. I don't see how that's supposed to be useful. Why not write a generic matrix class that creates a [n][m] matrix, and create special classes for special matrices that use this matrix class? That achieves the same thing, is much less complicated and most importantly, doesn't obfuscate what you are actually trying to do.