[lambda] Serialising Lmanda functions

Is there a 'standard' solution to this problem? #include <list> #include <iostream> #include "boost/lambda/lambda.hpp" typedef std::list<unsigned> List; std::ostream & operator<<( std::ostream & s, const List & ); int main( ) { using namespace boost::lambda; List my_list; ( std::cout << _1 << "\n" )( my_list ); } The compiler cannot find a match for operator<<() because the operator and the type are defined in different namespaces, but it's really a nuisance! - Rob.

On Tue, Oct 7, 2008 at 5:57 PM, Robert Jones <robertgbjones@gmail.com> wrote:
Is there a 'standard' solution to this problem?
#include <list> #include <iostream> #include "boost/lambda/lambda.hpp"
typedef std::list<unsigned> List; std::ostream & operator<<( std::ostream & s, const List & );
int main( ) { using namespace boost::lambda; List my_list;
( std::cout << _1 << "\n" )( my_list ); }
The compiler cannot find a match for operator<<() because the operator and the type are defined in different namespaces, but it's really a nuisance!
Dirty trick that might work: just write your own allocator that simply inherit from the standard allocator (you might need to add forwarding constructors). Put it in the same namespace you declare your operator<<, then typedef std::list<unsigned, my_alloc> List; ADL should take care of everything. -- gpd
participants (2)
-
Giovanni Piero Deretta
-
Robert Jones