
Christoph Ludwig wrote:
On Fri, May 14, 2004 at 09:14:53AM -0700, Robert Ramey wrote:
Christoph Ludwig wrote:
Is it possible with the serialization library to serialize function pointers and pointers to member functions? If it is not directly supported, is there a "best practice" workaround? I didn't find this info in the documentation.
There's no information in the documentation about this. I'm not sure what it would mean to serialize a function pointer.
I agree it's hard to come up with a unique external representation of the value of a function pointer. The most obvious candidate would be the name of the referenced function, but a) I have no idea whether this can be determined automatically and portably at runtime. b) it's likely to be implementation dependent, e.g., if the referenced function is defined inside an unnamed namespace.
What I do is register them manually. template<class T> void register_static( T * pt, std::string const & name ) { // add to name<->address maps } template<class T> void save(T * const & pt) { // look up the name of pt and save } template<class T> void load(T * & t) { // load name, look up address, store in pt }