Boost logo

Boost Users :

Subject: Re: [Boost-users] a quick question regarding boost::bind with a test case
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2011-04-11 15:07:08


AMDG

On 04/11/2011 11:19 AM, Littlefield, Tyler wrote:
> Hello:
> Here is what I'm going for; maybe this will explain
> I have the following code in my project:
> AddOlc("name", "Please enter the name of the object", STRING,
> boost::bind(OlcString, _1, _2, _3, boost::bind(&Entity::GetName, this),
> boost::bind(&Entity::SetName, this, _1)));
> OlcString:
> void OlcString(Entity* ed, Player* mob, const Variant* input,
> boost::function<std::string ()> get, boost::function<void (const
> std::string&)> set)
> {
> if (input->Typeof() != VAR_STR)
> {
> mob->Message(MSG_ERROR, "Invalid input.");
> return;
> }
>
> set(input->GetStr());
> }

Oh. If you're using nested binds like this,
you need to use protect.

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