|
Boost Users : |
Subject: Re: [Boost-users] [Bind] Unexpected behavior when bindingconstchar* to function
From: Pete Bartlett (pete_at_[hidden])
Date: 2010-04-28 20:36:56
Piotr Jachowicz wrote:
>I only wanted to express concern that when binding to function
>accepting pointers (which is misuse)
No, its not misuse to pass a pointer to bind. You'd just have to remember if
the pointed-to object changes prior to calling the function call operator of
the binder, then you end up using the changed object in your function call.
But there is nothing at all special about Bind here. Consider
struct T {
int something(){
/*some state-dependent calculation here*/
}
void change_me(){
/*change state here*/
}
};
struct A {
T* t;
int foo(){ return T->something(); }
};
int main()
{
T myT(...);
A a;
a.t = &myT;
myT.change_me();
return a.foo(); //the changes in "change_me" matter here
}
This is all "pointers 101", so why pick on Bind?
Pete
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