Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2005-09-28 10:49:56


All that is needed is a "function" which returns a pointer to a char string.

template<class T>
const char * guid();

So that one could write the following program - which compiles. I haven't
checked to see that it really works.

#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/export.hpp>
template<class T>
const char * guid();
struct X {
template<class Archive>
void serialize(Archive & ar, const unsigned int version){}
};
BOOST_CLASS_EXPORT_GUID(X, guid<X>())

Naturally this addresses all issues regarding registration of derived
pointers, template instantiation, etcetera.

Now the application doesn't need to create portable archives, its easy to
craft a version of guid() from type_info. call it type_info_guide() or
whatever.

I don't believe that type_info can be used to craft a function which returns
the same string accross different compilers. Then there is the issue that
some of the types X might not be in the same namespace in all executables.
So an implementation that meets Boost's requirements for portability and
robustness is probably not possible. But this in no way should inhibit one
from using it in his own context where appropriate.

Robert Ramey


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