Why don't you just derived all the functors from a common base and serialize a base class pointer? You wouldn't have to do anything special since polymorphic pointers are already addressed. Robert Ramey Chard wrote:
"Igor R"
wrote in message news:cfe0a3cf0909150846l4290d47yd03b8ea7f33e0b53@mail.gmail.com... Ok, thank you. So the way to go is to make "manual" function objects...
We have a system that serializes boost::function - they are used as factory objects that are sent through sockets (via asio).
We only support serializing boost::function with functors, but the mechanism works well. Fortunately, boost::function has the target<> method that can be used to get access to the original type.
As touched upon by an earlier post, we have to look up the types from some kind of registry that associates the boost::function (the signature) with the type (the functor) that can be assigned into it. This means we have to register each association, but this is similar to registering polymorphic class types (i.e. archive.register_type<>).
It may be possible to generalize the mechanism, but it would probably require a new export macro that can associate the types, e.g. a BOOST_FUNCTION_EXPORT(signature, func_name, type, type_name) to go along with BOOST_CLASS_EXPORT.