Re: [boost] [serialization] MSVC8 runtime check error

John Reid wrote:
I'm getting a runtime check error from MSVC8 in the following code checked out from cvs_head:
serialization/collections_load_imp.hpp line 116
...
template<class Archive, class Container, class InputFunction, class R> inline void load_collection(Archive & ar, Container &s) { s.clear(); // retrieve number of elements unsigned int count; unsigned int item_version; ar >> BOOST_SERIALIZATION_NVP(count); if(3 < ar.get_library_version()){ ar >> BOOST_SERIALIZATION_NVP(item_version); } R rx; rx(s, count); InputFunction ifunc; while(count-- > 0){ ifunc(ar, s, item_version); } }
I think this function would be more flexible if the clear call was removed. Users could decide if they want to call clear() or not. If you want append-like behaviour you wouldn't call clear(). If you know the container is already empty you also wouldn't have to call clear(). Regards, Brian Wood www.webEbenezer.net

brass goowy wrote:
John Reid wrote:
I'm getting a runtime check error from MSVC8 in the following code checked out from cvs_head:
serialization/collections_load_imp.hpp line 116
...
template<class Archive, class Container, class InputFunction, class R> inline void load_collection(Archive & ar, Container &s) { s.clear(); // retrieve number of elements unsigned int count; unsigned int item_version; ar >> BOOST_SERIALIZATION_NVP(count); if(3 < ar.get_library_version()){ ar >> BOOST_SERIALIZATION_NVP(item_version); } R rx; rx(s, count); InputFunction ifunc; while(count-- > 0){ ifunc(ar, s, item_version); } }
I think this function would be more flexible if the clear call was removed. Users could decide if they want to call clear() or not. If you want append-like behaviour you wouldn't call clear(). If you know the container is already empty you also wouldn't have to call clear().
I couldn't be convinced that this is a good idea. The "fixed idea" of the serialization library is that the >> operator reconstructs things as they were when the << operator was called. Having the operation of >> depend upon some non-obvious state variable would result in very error prone code - as it always does. Robert Ramey
Regards, Brian Wood www.webEbenezer.net _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (2)
-
brass goowy
-
Robert Ramey