#include USING_PART_OF_NAMESPACE_EIGEN using namespace std; template void foo(const MatrixBase& m) { cout << "Here's m:" << endl << m << endl; } template Eigen::ScalarMultiple twice(const MatrixBase& m) { return 2 * m; } int main(int, char**) { Matrix2d m = Matrix2d::random(); foo(m); foo(twice(m)); return 0; }