[lambda] Using Boost.Lambda with overloaded operators on user defined types

Hi! I can work around this one easily, but I'm really interested what's wrong with it, and spent 2 days searching in vain. I have in SnakeCube.h the following: typedef boost::multi_array<int, 3> SnakeCubeSolution_t; typedef std::tr1::function<void(const SnakeCubeSolution_t&)> SnakeCubeSolutionCallback_t; typedef std::vector<int> SnakeCubeConstraint_t; void solveSnakeCube( const SnakeCubePosition_t& constraint, SnakeCubeSolutionCallback_t callback); std::ostream& operator<< (std::ostream& out, SnakeCubeSolution_t solution); I included <vector> <ostream> <boost/tr1/functional.hpp> <boost/multi_array.hpp> Function implementations do not seem important, since the problem persists with empty functions. --- The part that won't compile is the last line of main.cpp (Error message at the end of the post) #include <algorithm> #include <iostream> #include <boost/assign/std/vector.hpp> #include <boost/lambda/lambda.hpp> #include "SnakeCube.h" using namespace std; using namespace boost::assign; int main(int argc, char* argv[]) { using boost::lambda::_1; SnakeCubeConstraint_t constraint; constraint += 0,0,1,1,1,0,1,1,0,1,1,1,0,1,0,1,1,1,1,0,1,0,1,0,1,0,0; solveSnakeCube( constraint, cout << _1); // Other versions I tried: //solveSnakeCube( constraint, boost::ref(cout) << _1); //solveSnakeCube( constraint, boost::lambda::ret<ostream&>( cout << _1 ) ); } The easy way out is renaming the operator to printSoution, and use bind(printSolution, boost::ref(cout), _1) instead of cout << _1. Can someone please point me in the right direction on this matter? Thanks, Rafael --------------- g++ -Wall --pedantic -ansi -O3 -o snakecube main.cpp SnakeCube.o In file included from /usr/include/boost/lambda/lambda.hpp:22:0, from main.cpp:6: /usr/include/boost/lambda/detail/operator_lambda_func_base.hpp: In member function ‘RET boost::lambda::lambda_functor_base<boost::lambda::bitwise_action<boost::lambda::leftshift_action>, Args>::call(A&, B&, C&, Env&) const [with RET = std::basic_ostream<char>&, A = const boost::multi_array<int, 3ul>, B = const boost::tuples::null_type, C = const boost::tuples::null_type, Env = const boost::tuples::null_type, Args = boost::tuples::tuple<std::basic_ostream<char>&, boost::lambda::lambda_functor<boost::lambda::placeholder<1> >, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>]’: /usr/include/boost/lambda/detail/lambda_functors.hpp:202:50: instantiated from ‘typename boost::lambda::lambda_functor<Base>::inherited::sig<boost::tuples::tuple<const A&> >::type boost::lambda::lambda_functor<Base>::operator()(const A&) const [with A = boost::multi_array<int, 3ul>, T = boost::lambda::lambda_functor_base<boost::lambda::bitwise_action<boost::lambda::leftshift_action>, boost::tuples::tuple<std::basic_ostream<char>&, boost::lambda::lambda_functor<boost::lambda::placeholder<1> >, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >, typename boost::lambda::lambda_functor<Base>::inherited::sig<boost::tuples::tuple<const A&> >::type = std::basic_ostream<char>&]’ /usr/include/boost/function/function_template.hpp:153:11: instantiated from ‘static void boost::detail::function::void_function_obj_invoker1<FunctionObj, R, T0>::invoke(boost::detail::function::function_buffer&, T0) [with FunctionObj = boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::bitwise_action<boost::lambda::leftshift_action>, boost::tuples::tuple<std::basic_ostream<char>&, boost::lambda::lambda_functor<boost::lambda::placeholder<1> >, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> > >, R = void, T0 = const boost::multi_array<int, 3ul>&]’ /usr/include/boost/function/function_template.hpp:913:60: instantiated from ‘void boost::function1<R, T1>::assign_to(Functor) [with Functor = boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::bitwise_action<boost::lambda::leftshift_action>, boost::tuples::tuple<std::basic_ostream<char>&, boost::lambda::lambda_functor<boost::lambda::placeholder<1> >, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> > >, R = void, T0 = const boost::multi_array<int, 3ul>&]’ /usr/include/boost/function/function_template.hpp:722:7: instantiated from ‘boost::function1<R, T1>::function1(Functor, typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type) [with Functor = boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::bitwise_action<boost::lambda::leftshift_action>, boost::tuples::tuple<std::basic_ostream<char>&, boost::lambda::lambda_functor<boost::lambda::placeholder<1> >, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> > >, R = void, T0 = const boost::multi_array<int, 3ul>&, typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type = int]’ /usr/include/boost/function/function_template.hpp:1064:16: instantiated from ‘boost::function<R(T0)>::function(Functor, typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type) [with Functor = boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::bitwise_action<boost::lambda::leftshift_action>, boost::tuples::tuple<std::basic_ostream<char>&, boost::lambda::lambda_functor<boost::lambda::placeholder<1> >, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> > >, R = void, T0 = const boost::multi_array<int, 3ul>&, typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type = int]’ main.cpp:28:44: instantiated from here /usr/include/boost/lambda/detail/operator_lambda_func_base.hpp:212:1: error: no match for ‘operator<<’ in ‘boost::lambda::detail::select [with Any = std::basic_ostream<char>, A = const boost::multi_array<int, 3ul>, B = const boost::tuples::null_type, C = const boost::tuples::null_type, Env = const boost::tuples::null_type]((* & boost::tuples::get [with int N = 0, HT = std::basic_ostream<char>&, TT = boost::tuples::cons<boost::lambda::lambda_functor<boost::lambda::placeholder<1>
, boost::tuples::null_type>, typename boost::tuples::access_traits<typename boost::tuples::element<N, boost::tuples::cons<HT, TT> >::type>::const_type = std::basic_ostream<char>&]((* &((const boost::lambda::lambda_functor_base<boost::lambda::bitwise_action<boost::lambda::leftshift_action>, boost::tuples::tuple<std::basic_ostream<char>&, boost::lambda::lambda_functor<boost::lambda::placeholder<1> >, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> *)this)->boost::lambda::lambda_functor_base<boost::lambda::bitwise_action<boost::lambda::leftshift_action>, boost::tuples::tuple<std::basic_ostream<char>&, boost::lambda::lambda_functor<boost::lambda::placeholder<1> >, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> ::args.boost::tuples::tuple<std::basic_ostream<char>&, boost::lambda::lambda_functor<boost::lambda::placeholder<1> >, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>::<anonymous>))), (* & a), (* & b), (* & c), (* & env)) << boost::lambda::detail::select [with Arg = boost::lambda::placeholder<1>, A = const boost::multi_array<int, 3ul>, B = const boost::tuples::null_type, C = const boost::tuples::null_type, Env = const boost::tuples::null_type, typename Arg::sig<boost::tuples::tuple<A&, B&, C&, Env&> >::type = const boost::multi_array<int, 3ul>&]((* & boost::tuples::get [with int N = 1, HT = std::basic_ostream<char>&, TT = boost::tuples::cons<boost::lambda::lambda_functor<boost::lambda::placeholder<1> , boost::tuples::null_type>, typename boost::tuples::access_traits<typename boost::tuples::element<N, boost::tuples::cons<HT, TT> >::type>::const_type = const boost::lambda::lambda_functor<boost::lambda::placeholder<1> >&]((* &((const boost::lambda::lambda_functor_base<boost::lambda::bitwise_action<boost::lambda::leftshift_action>, boost::tuples::tuple<std::basic_ostream<char>&, boost::lambda::lambda_functor<boost::lambda::placeholder<1> >, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> *)this)->boost::lambda::lambda_functor_base<boost::lambda::bitwise_action<boost::lambda::leftshift_action>, boost::tuples::tuple<std::basic_ostream<char>&, boost::lambda::lambda_functor<boost::lambda::placeholder<1> >, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> ::args.boost::tuples::tuple<std::basic_ostream<char>&, boost::lambda::lambda_functor<boost::lambda::placeholder<1> >, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>::<anonymous>))), (* & a), (* & b), (* & c), (* & env))’ /usr/include/boost/lambda/detail/operator_lambda_func_base.hpp:212:1: note: candidates are: /usr/include/c++/4.6/ostream:110:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ostream_type& (*)(std::basic_ostream<_CharT, _Traits>::__ostream_type&)) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/include/c++/4.6/ostream:110:7: note: no known conversion for argument 1 from ‘const boost::multi_array<int, 3ul>’ to ‘std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&) {aka std::basic_ostream<char>& (*)(std::basic_ostream<char>&)}’ /usr/include/c++/4.6/ostream:119:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ios_type& (*)(std::basic_ostream<_CharT, _Traits>::__ios_type&)) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>, std::basic_ostream<_CharT, _Traits>::__ios_type = std::basic_ios<char>] /usr/include/c++/4.6/ostream:119:7: note: no known conversion for argument 1 from ‘const boost::multi_array<int, 3ul>’ to ‘std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&) {aka std::basic_ios<char>& (*)(std::basic_ios<char>&)}’ /usr/include/c++/4.6/ostream:129:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/include/c++/4.6/ostream:129:7: note: no known conversion for argument 1 from ‘const boost::multi_array<int, 3ul>’ to ‘std::ios_base& (*)(std::ios_base&)’ /usr/include/c++/4.6/ostream:167:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/include/c++/4.6/ostream:167:7: note: no known conversion for argument 1 from ‘const boost::multi_array<int, 3ul>’ to ‘long int’ /usr/include/c++/4.6/ostream:171:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/include/c++/4.6/ostream:171:7: note: no known conversion for argument 1 from ‘const boost::multi_array<int, 3ul>’ to ‘long unsigned int’ /usr/include/c++/4.6/ostream:175:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/include/c++/4.6/ostream:175:7: note: no known conversion for argument 1 from ‘const boost::multi_array<int, 3ul>’ to ‘bool’ /usr/include/c++/4.6/bits/ostream.tcc:93:5: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char, _Traits = std::char_traits<char>] /usr/include/c++/4.6/bits/ostream.tcc:93:5: note: no known conversion for argument 1 from ‘const boost::multi_array<int, 3ul>’ to ‘short int’ /usr/include/c++/4.6/ostream:182:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/include/c++/4.6/ostream:182:7: note: no known conversion for argument 1 from ‘const boost::multi_array<int, 3ul>’ to ‘short unsigned int’ /usr/include/c++/4.6/bits/ostream.tcc:107:5: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char, _Traits = std::char_traits<char>] /usr/include/c++/4.6/bits/ostream.tcc:107:5: note: no known conversion for argument 1 from ‘const boost::multi_array<int, 3ul>’ to ‘int’ /usr/include/c++/4.6/ostream:193:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/include/c++/4.6/ostream:193:7: note: no known conversion for argument 1 from ‘const boost::multi_array<int, 3ul>’ to ‘unsigned int’ /usr/include/c++/4.6/ostream:202:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/include/c++/4.6/ostream:202:7: note: no known conversion for argument 1 from ‘const boost::multi_array<int, 3ul>’ to ‘long long int’ /usr/include/c++/4.6/ostream:206:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/include/c++/4.6/ostream:206:7: note: no known conversion for argument 1 from ‘const boost::multi_array<int, 3ul>’ to ‘long long unsigned int’ /usr/include/c++/4.6/ostream:211:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/include/c++/4.6/ostream:211:7: note: no known conversion for argument 1 from ‘const boost::multi_array<int, 3ul>’ to ‘double’ /usr/include/c++/4.6/ostream:215:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/include/c++/4.6/ostream:215:7: note: no known conversion for argument 1 from ‘const boost::multi_array<int, 3ul>’ to ‘float’ /usr/include/c++/4.6/ostream:223:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/include/c++/4.6/ostream:223:7: note: no known conversion for argument 1 from ‘const boost::multi_array<int, 3ul>’ to ‘long double’ /usr/include/c++/4.6/ostream:227:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/include/c++/4.6/ostream:227:7: note: no known conversion for argument 1 from ‘const boost::multi_array<int, 3ul>’ to ‘const void*’ /usr/include/c++/4.6/bits/ostream.tcc:121:5: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__streambuf_type*) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__streambuf_type = std::basic_streambuf<char>] /usr/include/c++/4.6/bits/ostream.tcc:121:5: note: no known conversion for argument 1 from ‘const boost::multi_array<int, 3ul>’ to ‘std::basic_ostream<char>::__streambuf_type* {aka std::basic_streambuf<char>*}’ /usr/include/boost/lambda/detail/operators.hpp:114:1: note: template<class Arg, class B> const boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::bitwise_action<boost::lambda::leftshift_action>, boost::tuples::tuple<boost::lambda::lambda_functor<Arg>, typename boost::lambda::const_copy_argument<const B>::type> > > boost::lambda::operator<<(const boost::lambda::lambda_functor<Arg>&, const B&) /usr/include/boost/lambda/detail/operators.hpp:114:1: note: template<class A, class Arg> const boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::bitwise_action<boost::lambda::leftshift_action>, boost::tuples::tuple<typename boost::lambda::const_copy_argument<const A>::type, boost::lambda::lambda_functor<Arg> > > > boost::lambda::operator<<(const A&, const boost::lambda::lambda_functor<Arg>&) /usr/include/boost/lambda/detail/operators.hpp:114:1: note: template<class ArgA, class ArgB> const boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::bitwise_action<boost::lambda::leftshift_action>, boost::tuples::tuple<boost::lambda::lambda_functor<Arg>, boost::lambda::lambda_functor<Arg> > > > boost::lambda::operator<<(const boost::lambda::lambda_functor<Arg>&, const boost::lambda::lambda_functor<Arg>&) /usr/include/boost/lambda/detail/operators.hpp:205:1: note: template<class A, class Arg> const boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::bitwise_action<boost::lambda::leftshift_action>, boost::tuples::tuple<typename boost::lambda::detail::convert_ostream_to_ref_others_to_c_plain_by_default<A>::type, boost::lambda::lambda_functor<Arg> > > > boost::lambda::operator<<(A&, const boost::lambda::lambda_functor<Arg>&) /usr/include/boost/lambda/detail/operators.hpp:222:1: note: template<class Arg, class Ret, class ManipArg> const boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::bitwise_action<boost::lambda::leftshift_action>, boost::tuples::tuple<boost::lambda::lambda_functor<Arg>, Ret (&)(ManipArg)>
boost::lambda::operator<<(const boost::lambda::lambda_functor<Arg>&, Ret (&)(ManipArg)) /usr/include/c++/4.6/complex:521:5: note: template<class _Tp, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::complex<_Tp>&) /usr/include/c++/4.6/ostream:528:5: note: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const unsigned char*) /usr/include/c++/4.6/ostream:523:5: note: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const signed char*) /usr/include/c++/4.6/ostream:510:5: note: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const char*) /usr/include/c++/4.6/bits/ostream.tcc:323:5: note: template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const char*) /usr/include/c++/4.6/ostream:493:5: note: template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const _CharT*) /usr/include/c++/4.6/ostream:473:5: note: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, unsigned char) /usr/include/c++/4.6/ostream:468:5: note: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, signed char) /usr/include/c++/4.6/ostream:462:5: note: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, char) /usr/include/c++/4.6/ostream:456:5: note: template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, char) /usr/include/c++/4.6/ostream:451:5: note: template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, _CharT) /usr/include/c++/4.6/bits/basic_string.h:2693:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&)

Here's a much smaller example that reproduces the problem: #include <iostream> #include <boost/tr1/functional.hpp> #include <boost/lambda/lambda.hpp> namespace foo { struct S { }; } using foo::S; std::ostream& operator<< (std::ostream&, S); int main() { using boost::lambda::_1; std::tr1::function<void(S)> c = std::cout << _1; } This gives similar errors, but if you move struct S from namespace foo to the global namespace, it works. Similarly, if you move the operator<< from the global namespace to namespace foo, it works. So I guess the problem is with where Boost.Lambda looks for the operator. It seems to only look in the same namespace where the operator was declared. I'm not sure how to solve it, unfortunately. Perhaps someone familiar with the internals of Boost.Lambda can comment. You may also want to consider using Boost.Phoenix instead. It's supposed to be a new-and-improved version of Boost.Lambda, perhaps it doesn't have this problem. Regards, Nate
participants (2)
-
DeVill
-
Nathan Ridge