|
Boost : |
From: Robert Dailey (rcdailey_at_[hidden])
Date: 2008-03-13 23:03:40
On Thu, Mar 13, 2008 at 5:43 PM, Giovanni Piero Deretta <gpderetta_at_[hidden]>
wrote:
> On Thu, Mar 13, 2008 at 11:18 PM, Robert Dailey <rcdailey_at_[hidden]>
> wrote:
> > Hi,
> >
> > Currently I have a class named Foo. Foo is using Boost.Bind to bind one
> of
> > its own private methods to *this. However, since the method I'm binding
> is
> > private, boost.bind cannot call it.
>
> This compiles for me with gcc:
>
> #include <boost/bind.hpp>
> class foo {
> private:
> void do_bind() {
> int i = boost::bind(&foo::m, _1)(this);
> }
> int m;
> };
>
> in fact the privateness of the member shouldn't matter.
> Once you extract the pointer to member, access control doesn't matter
> any longer.
> Of course you need to extract the pointer to member inside a member
> function or a friend of the class,
> but bind shouldn't have nothing to do with that.
>
> > Is there a way to make Boost.Bind a
> > friend of my class? What is the recommended solution to such a problem?
> I
> > did some quick searching on google about this issue but I came up with
> no
> > results. Thanks.
>
> What is the problem you are encountering exactly?
The private member function I'm binding is being passed into
Boost.Signalslibrary, and that is where the function object is being
evoked. Perhaps that
is the issue? The function bound by Boost.Bind() is being evoked outside of
the scope of the owning class. Perhaps Boost.Signals needs to be a friend?
When I get into work tomorrow I'll give you an exact compiler error message,
if you require it. The compiler error itself wasn't at all helpful, it was
simply my assumption that binding a private member function to
boost.bindwasn't going to work.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk