
on Fri Jul 11 2008, "Robert Jones" <robertgbjones-AT-gmail.com> wrote:
Is it possible to invoke user defined streaming operators within boost lambda functions? In this style
#include <iostream> #include <map> #include "boost/lambda/lambda.hpp"
using namespace std;
ostream & operator << ( ostream & ostrm, pair<string, string> const & input );
ostream & operator << ( ostream & ostrm, map<string, string> & inputs ) { using namespace boost :: lambda;
for_each ( inputs.begin( ), inputs.end( ), ostrm << _1 << '\n' ); return ostrm; }
Yes, something like that works.
Is this basically undoable, or am I doing it wrong?
Why would you think either one was true? Note that std::endl can cause you big troouble, but since you're using '\n' above I don't see a reason to worry. You do need something like "using namespace boost::lambda;" to make "_1" valid, though.
Also, does the online Comeau compiler understand the boost include directives?
That's a question for Comeau. HTH, -- Dave Abrahams BoostPro Computing http://www.boostpro.com