|
Boost Users : |
Subject: Re: [Boost-users] Beginner question: Why boost::signal creates another instance of the slot object ?
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-08-19 18:20:03
AMDG
Mauricio Gomes wrote:
> I am running the program below (Vista with boost 1.43, mingw/gcc 4.5.1).
>
> I would expect slot.x to be 5 but it is zero.
>
> Why boost::signal creates another instance of the slot object ?
> What am I missing here ?
boost::signal stores a copy of the function object. If you
don't want to make a copy use boost::ref.
sig.connect(boost::ref(f));
If you do this, you need to be careful that the
function object doesn't go out of scope too soon.
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