Boost logo

Boost Users :

From: Alejandro Martinez (elpeque2_at_[hidden])
Date: 2008-08-07 09:51:18


After i define a boost::function using bind to a member function of some
signature...

Can i change the instance to have as "this" in such function for another of
the same type? Maybe pass it as a parameter at call time?

Why would i want that?

Imagine i have some class A that dispatches calls for a big amount of
methods. The requests for such calls come serialized, and the method is
selected by its name (string).

So there should be a std::map<std::string, boost::function<some_signature> >
to be able to make the actual call after i know what the name is without
doing a switch or a huge ammount of ifs.

So A has that map, and has it populated with member functions of itself.

But i may have many instances of A. (actually, one for each of many
threads). So having that map in each is a waste of resources. So maybe i
could declare the map as static, so that it is shared between all instances
of A. But to do that, i would need to be able to tell the function in the
map im about to invoke, what its "this" should be at this time.

Did i explain myself clearly?

Thanks a lot for your time :)


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