Prevent expression templates binding to rvalue references
I understand that doing something like the following: auto&& x = Matrix1() + Matrix2() + Matrix3(); std::cout << x(2,3) << std::endl; Will cause a silent runtime error if the matrix operations use expression templates (such as boost::ublas ). Is there any way of designing expression templates to prevent the compiler from compiling such code that may result in the use of expired temporaries at runtime? (I've attempted unsuccessfully to work around this issue, the attempt is here ) Is there any way of designing expression templates to prevent the compiler from compiling such code that may result