Robert Ramey wrote:
template<class T> class any_value_holder { static boost::proably_not_yet_written::serialization_register< any_value_holder<T> > register_it; };
Is it possible to make this work?
I think you would also need to explicitly instantiate it for each type. Which puts us back to square one of having to specify the types ahead of time.
With some cooperation from boost::any, this is not necessary: template<class T> class any_holder { public: any_holder() { ®istrator_; } private: static registrator<T> registrator_; }; will run constructor of 'registrator_' while generating no code in any_holder's constructor. Complete example attached.
Its possible that progress could be made here, but I think it would be pretty tricky. Here are some off hand ideas.
It seems to me that boost::any is a basically a wrapper around a pointer to a type ValueType. If ValueType is exported it would possible to make things work. However, boost::any public interface doesn't expose enough of its public interface to make it serializable. So if one wanted to do this he would have to do one of the following:
a) make some private variables public b) add some functions to expose required implementation features
Namely? boost::any already has const std::type_info & type() const; method and if it can be used to implement non-intrusive serialization, this will be great. - Volodya