Boost logo

Boost Users :

From: Doug Gregor (dgregor_at_[hidden])
Date: 2008-03-14 09:37:59


On Mar 6, 2008, at 5:18 AM, Cory Nelson wrote:

> Hi guys, ran across a question that I'd have thought would be at least
> common enough to get a note in the docs, but I can't find it there.
>
> Is it safe to set a function from within a call on the function?
>
> boost::function<void()> f;
>
> void func2();
>
> void func1() {
> f = func2;
> }
>
> void main() {
> f = func1;
> f();
> }

As long as the function object being called by the boost::function
doesn't mind having its state disappear, it's fine.

        - Doug


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