Boost logo

Boost :

Subject: Re: [boost] Boost.Local Review (Nov 10, 2011 to Nov 19, 2011)
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2011-11-18 13:31:42


On Fri, Nov 18, 2011 at 1:44 AM, Lorenzo Caminiti <lorcaminiti_at_[hidden]>wrote:

> On Wed, Nov 16, 2011 at 10:24 AM, Lorenzo Caminiti
>
[...]

> boost::function<void (int&)> counter() {
> int delta = 2;
> void BOOST_CLOSURE(int& x, bind delta) {
>

Of course, you meant "bind x" or "int x" here instead of "int& x", right?

> x += delta;
> std::cout << "x = " << x << std::endl;
> } BOOST_CLOSURE_END(increment)
> return increment;
> }
>
> int main() {
> int x = 1;
> boost::function<void (int&)> inc = counter();
> inc(x); // undefined behaviour now but it should work...
> return 0;
> }
>
[...]

- Jeff


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk