Registered Member
|
I write the following method:
I know it'd work if instead of Matrix<T, 3, 1> I had, for instance, Vector3d. However I'd like to have the method templatized on the scalar type only. The method should work with any kind of vector that is contiguous in memory either a Matrix<T, 3, 1>, a block or a map. However when trying to pass a Vector3d to the previous method I get a compile error like so:
why doesn't this code compile? is there a way to accomplish this without using MatrixBase? (for my application I do know these arguments will be contiguous in memory but I'd like to explicit instantiate my method and the number of options increases very rapidly!) Thank you in advance. |
Moderator
|
This cannot compile because template deduction with type conversion only works for static casts to a base class. So:
- MatrixXd -> MatrixBase<Derived> : OK - MatrixXd -> Ref<Matrix<T> > : not OK Ref has been especially designed to enable some level of genericity without having to rely on template. So in your case better use a generic MatrixBase<Derived> with a static assertion on the sizes. |
Registered Member
|
I realized I never replied to this. Thank you ggael for your prompt response.
|
Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]