|[eigen] const references (bug 218)|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
I have a question/comment on bug 218
The bug is closed as wontfix, but I suspect that it might be legitimate,
hence my post here.
Visual Studio users get the following warning: C4181: qualifier applied
to reference type; ignored
This happens for example inside MatrixBase<Derived>::cross
(OrthoMethods.h, line 46)
The offending code is: const typename internal::nested<Derived,2>::type
Now my question:
Why do we have a const keyword there?
If internal::nested<Derived,2>::type turns out to be a reference type,
the const is applied to the reference and not to the referenced type and
the warning is legitimate (references are always constant). Also,
internal::nested uses ref_selector, and ref_selector<T>::type is already
a reference to const T, so no need for an additional const.
If internal::nested<Derived,2>::type turns out to be a plain type, the
const keyword might help the compiler optimize code, which would however
surprise me here. If the const is really helpful, a new member
internal::nested::const_type might be more appropriate.