Boost logo

Boost Users :

From: Matthias Troyer (troyer_at_[hidden])
Date: 2007-12-08 00:39:48


On 8 Dec 2007, at 07:55, 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.

Indeed there is too much type erasure happening here. What is it that
you don't like with vector<shared_ptr<somefunctionObject> >?

Matthias


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