In-Reply-To: <[EMAIL PROTECTED]> On Sat, 16 Nov 2002 22:50:23 -0800 Robert Ramey ([EMAIL PROTECTED]) wrote: > A default constructor is not required. The reference section > "Serialization Overrides" explains this and gives a code excerpt > showing what one has to do to use a constructor with arguments.
The code looks roughly like: ar >> a; t = new T(a); ar >> *t; Is it possible to support code like: t = new T(ar); Or indeed: const T t(ar); ? It seems to me that your versioning infrastructure doesn't support this. At first sight this seems like a problem. I am not sure if this if it is a killer, mainly because I can see it can be difficult to get robust versioning in complex cases. Eg this seems natural: class MyClass { const MyMember m_member1; const MyMember m_member2; public: MyClass( boost::basic_iarchive &ar ) : m_member1(ar), m_member2(ar) { } }; and something like this is surely the only way to support const members. However, if we need to add or remove members, as written we don't have a version number to tell us what to do and it would be hard to put much processing in the member initialisation list anyway. That said, something like: class MyClass { MyMember m_member1; MyMember m_member2; public: MyClass( boost::basic_iarchive &ar ) { boost::version_type version = ar.version(); if (version > 1) MyMember(ar).swap( m_member1 ); if (version > 2) MyMember(ar).swap( m_member2 ); } }; could be possible as a partial solution. We've lost const members and the approach doesn't help with base classes. However, const instances of MyClass itself can be loaded, and we have more of the construction code inside the constructor. Is it your belief that this kind of thing is best discouraged? If so, maybe there should be something about it in the rationale. -- Dave Harris _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost