The return type of valarray's sqrt function isn't valarray, as specified in 26.3.3.3 [lib.valarray.transcend], and what it does return doesn't convert to valarray in some cases. This causes the slice1.cpp example from the Josuttis book examples to get a compile error:
http://www.josuttis.com/libbook/num/slice1.cpp.html g++ gives this error: slice1.cpp:48: error: no matching function for call to ‘printValarray(std::_Expr<std::_UnClos<std::__sqrt, std::_ValArray, double>, double>)’ Here's a reduced form which still shows the error: #include <valarray> using namespace std; template<class T> void printValarray (const valarray<T>& va); void foo(void) { valarray<double> v; printValarray (sqrt(v)); } -- Summary: return type of valarray's sqrt function isn't valarray Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: djg at cray dot com GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28414