Reputation: 397
consider the following test
Eigen::MatrixXd B(Eigen::MatrixXd::Random(5,5));
const Eigen::MatrixXd C(Eigen::MatrixXd::Random(5,5));
std::cout << "B " << typeid(B).name() << std::endl;
std::cout << "C " << typeid(C).name() << std::endl;
std::cout << " === " << std::endl;
std::cout << "B.T " << typeid(B.transpose()).name() << std::endl;
std::cout << "C.T " << typeid(C.transpose()).name() << std::endl;
and its output
B N5Eigen6MatrixIdLin1ELin1ELi0ELin1ELin1EEE
C N5Eigen6MatrixIdLin1ELin1ELi0ELin1ELin1EEE
===
B.T N5Eigen9TransposeINS_6MatrixIdLin1ELin1ELi0ELin1ELin1EEEEE
C.T N5Eigen9TransposeIKNS_6MatrixIdLin1ELin1ELi0ELin1ELin1EEEEE
demangled
B Eigen::Matrix<double, -1, -1, 0, -1, -1>
C Eigen::Matrix<double, -1, -1, 0, -1, -1>
===
B.T Eigen::Transpose<Eigen::Matrix<double, -1, -1, 0, -1, -1> >
C.T Eigen::Transpose<Eigen::Matrix<double, -1, -1, 0, -1, -1> const>
Why is C
not shown as const
? How does Eigen figure out it is? Is this an Eigen issue or is this typeid
?
Upvotes: 1
Views: 408
Reputation: 110658
This is due to the behaviour of typeid
:
§5.2.8/5 [expr.typeid] The top-level cv-qualifiers of the glvalue expression or the type-id that is the operand of
typeid
are always ignored.
So in both cases, the typeid
will only apply to Eigen::MatrixXd
.
Upvotes: 2