Boost logo

Boost Users :

Subject: Re: [Boost-users] [lambda] Using Boost.Lambda with overloaded operators on user defined types
From: Nathan Ridge (zeratul976_at_[hidden])
Date: 2011-11-19 16:43:58


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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net