
Hmmm ... i have used non-intrusive serialization on a function object without problems. So I don't see a problem here so I'm clearly missing something. Robert Ramey Ruediger Berlich wrote:
Hi there,
I have a class that is being serialized in regular intervals. It contains a vector<shared_ptr<somefunctionObject> > . As the somefunctionObject objects can maintain state, I want to be able to serialize them along with the surrounding class. This works fine with the current design.
I would find it much more pleasing to replace the above vector e.g. with a vector<boost::function<void(someType)> >. From the program logic this would have the same effect, but would be more elegant.
I can not see, though, how serialization would work in this case. As far as I know it is not possible to retrieve the object back from boost::function. And it is also not possible to specify more than one interface to boost::function, e.g. in order to support two operator() with different signatures like this:
"boost::function<void(someFunctionObkject), someFunctionObject(void)> f;"
If that was possible, I could just give the function object a "clone" function and write my own (de-)serialization code.
Any ideas ?
Thanks and Best Regards, Ruediger Berlich