
On Fri, 09 Sep 2005 15:43:58 -0300, Robert Ramey <ramey@rrsd.com> wrote:
if that's what you want to do - don't look too deeply into export.hpp.
The key macro is BOOST_CLASS_EXPORT_GUID(class, "name) and
BOOST_CLASS_EXPORT(T) is just
#define BOOST_CLASS_EXPORT(T) BOOST_CLASS_EXPORT_GUID(T, "T") // sort of
So the best would be for you to make something like:
template<class T> const char * name_from_type<T>()
You meant this, right?: template<class T> const char * name_from_type()/*<T>*/ { }
so one could say BOOST_CLASS_EXPORT_GUID(T, name_from_type<T>)
I don't understand how BOOST_CLASS_EXPORT_GUID would work that way. There has to be a call to this macro for each type, and all calls have to be at global scope. What I have now is: template<class T> const char * name_from_type() { return typeid(T).name(); } struct base { template<class Archive> void serialize(Archive&, unsigned) { } virtual ~base() {} }; template<class T> struct registor { registor(); }; template<class T> struct derived : base { T t; derived(T t) : t(t) { boost::serialization::type_info_implementation<derived<T> >:: type::export_register(name_from_type<derived<T> >()); boost::archive::detail::export_impl::for_each_archive<boost:: archive::detail::known_archive_types::type, derived<T> >:: instantiate(); } template<class Archive> void serialize(Archive& ar, unsigned) { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(base); ar & BOOST_SERIALIZATION_NVP(t); } static registor<T> reg; }; template<class T> registor<T>::registor() { boost::serialization::type_info_implementation<derived<T> >:: type::export_register(name_from_type<derived<T> >()); boost::archive::detail::export_impl::for_each_archive<boost:: archive::detail::known_archive_types::type, derived<T> >:: instantiate(); } template<class T> registor<T> derived<T>::reg; However, possible interactions with the linker, etc., make me nervous about this solution. The serialization lib takes precautions, but going this deep into export.hpp implementation bypasses them all. Can BOOST_CLASS_EXPORT_GUID be used after all for this? Is there a better way to do this? With the Itanium ABI making it's way into gcc, the typeinfo::name hack doesn't look so bad. It would be great if hooking export this way were easier. Thanks, Bruno