Boost logo

Boost Users :

Subject: Re: [Boost-users] [lambda] delayed assignment to a member
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-10-29 15:15:35


AMDG

Igor R wrote:
>> (lambda::var(member_) = 5)
>>
>
> Did you mean &my_obj::member_?

No. I meant exactly what I said.

> But anyway, it doesn't compile.
>

The following works fine.

#include <boost/lambda/lambda.hpp>
#include <boost/function.hpp>
#include <cassert>

struct S {
    int member_;
    void f() {
        boost::function<void()> f_(boost::lambda::var(member_) = 5);
        f_();
    }
};

int main() {
    S s;
    s.f();
    assert(s.member_ == 5);
}

> My real code should look like this:
>
> io_service.post(lambda::var(member_)=5); // posts to another thread
> and performs the assignment there
>

In Christ,
Steven Watanabe


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