Boost logo

Boost Users :

From: Stuart Dootson (stuart.dootson_at_[hidden])
Date: 2005-08-21 03:32:52


On 8/20/05, jll_at_[hidden] <jll_at_[hidden]> wrote:
> Hello,
>
> I'm just discovering Boost, and it looks great. However, I can't get
> the following code to work. I use g++ (GCC) 3.4.4 20050721 and boost
> 1.32 (also tried 1.33). When I try a similar example with mere
> integers it works though...
>
> #include <string>
> #include <sstream>
> #include <iterator>
> #include <vector>
> #include <boost/lambda/bind.hpp>
> #include <boost/lambda/lambda.hpp>
>
> using namespace std;
> using namespace boost::lambda;
>
> int main() {
> vector<string> cols;
> cols.push_back("foo");
> string prefix = "t1.";
> for_each(cols.begin(), cols.end(), _1 = prefix + _1);
> cout << cols.front() << endl;
> return 0;
> }
>

<snip errors>

>
>
> --
> Jean-Louis Leroy
> Sound Object Logic
> http://www.soundobjectlogic.com
>

The easiest way I've found is to override the operator+ return type,
i.e. change your lambda expression to:

_1 = ret<string>(prefix + _1)

Stuart Dootson


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