
Simon Buchan
Bruno MartÃnez wrote:
Hi.
When using pointers to functions with bind, the particular function doesn't play a part in the return value's type of bind. That is
void func1(); void func2();
typeid(boost::bind(&func1)) == typeid(boost::bind(&func1)) // this is true
I need the types to be different to store bind objects with the serialization library. The C++ Templates book proposes an adaptor that takes the pointer to function as a template parameter. However, this adaptor is particular to a given signature, and I don't know how to rewrite it more generally. Is this possible? Can I more easily make boost::bind do what I want?
Bruno You may be making more work for yourself than you need to, why do you need to serialize bind objects? I haven't used the serialization lib, but a quick look-through doesn't really bring any times to mind where I would want to serialize a boost::bind functor!
I would like to do the same thing - boost::bind can be used to bind an instance of an object, a member function pointer _and_ any parameters required by that function. This leads to a really useful implementation of the command pattern - you can build a list of these functors which constitute a composite command, and to serialise the whole lot - or part - would be invaluable in all sorts of situations including tracking how much of the composite command had actually been implemented. Maybe I should generalise and boostify my implementation. Any interest? S