#include #include #include struct output_array_value { public: output_array_value(std::ostream &out): out_(out) { } template < typename ValueType > void operator()(ValueType const &value) { out_ << value << " "; } private: std::ostream &out_; }; template < typename ValueType, unsigned int Size > std::ostream& operator << (std::ostream &out, std::tr1::array < ValueType, Size > const &array) { using namespace boost::lambda; out << "[ "; //std::for_each(array.begin(), array.end(), out << _1 << " "); // the problematic line std::for_each(array.begin(), array.end(), output_array_value(out)); out << "]"; return out; } int main() { std::tr1::array < float, 3 > vec3; std::tr1::array < std::tr1::array < float, 4 > , 4 > mat4x4; std::cout << vec3 << std::endl; // always ok std::cout << mat4x4 << std::endl; // only ok when the lambda line above is NOT used; otherwise, it fails to compile return 0; }