The following code unexpectedly assigns (0, -1, 0) instead of (0, 1, 0) as intended. Why? Any ideas?
#include <Eigen/Dense>
int main()
{
const bool useFirst = false;
// This is the original use-case.
const Eigen::Vector3d vect1
= useFirst ? -Eigen::Vector3d::UnitZ() : Eigen::Vector3d::UnitY();
// This version is somewhat simplified, but exhibits the same problem.
const Eigen::Vector3d unitZ(0.0, 0.0, 1.0), unitY(0.0, 1.0, 0.0);
const Eigen::Vector3d vect2 = useFirst ? -unitZ : unitY;
// FYI, this version does not compile (?).
// const Eigen::Vector3d vect3
// = useFirst ? -unitZ : Eigen::Vector3d::UnitY();
}