#include USING_PART_OF_NAMESPACE_EIGEN using namespace std; template Eigen::Column firstColumn(MatrixBase& m) { return Eigen::Column(m.ref(), 0); } template const Eigen::Column firstColumn(const MatrixBase& m) { return Eigen::Column(m.ref(), 0); } int main(int, char**) { Matrix4d m = Matrix4d::identity(); cout << firstColumn(2*m) << endl; // calls the const version firstColumn(m) *= 5; // calls the non-const version cout << "Now the matrix m is:" << endl << m << endl; return 0; }