|
Boost : |
From: Corrado Zoccolo (czoccolo_at_[hidden])
Date: 2007-12-04 09:01:53
On Dec 4, 2007 11:18 AM, Hervé Brönnimann <hervebronnimann_at_[hidden]> wrote:
>
> text_iarchive_impl<Archive>::load(std::string &s)
> {
> std::size_t size;
> * this->This() >> size;
> // skip separating space
> is.get();
> // borland de-allocator fixup
> #if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101))
> if(NULL != s.data())
> #endif
> + s = std::string();
> s.resize(size);
> is.read(const_cast<char *>(s.data()), size); // <== This looks
> suspect
> }
>
> Compared to Corrado's implementation, it's almost the same, but frees
> up resources earlier. You may actually be able to reuse the same
> block of memory for the resize() that you just freed.
>
This doesn't enforce strong exception safety.
My solution either modified the string with the deserialized value, or it
kept the original value.
This one may leave the string empty.
Corrado
> HTH,
> --
> Hervé Brönnimann
> hervebronnimann_at_[hidden]
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
-- __________________________________________________________________________ dott. Corrado Zoccolo mailto:zoccolo_at_[hidden] PhD - Department of Computer Science - University of Pisa, Italy -------------------------------------------------------------------------- The self-confidence of a warrior is not the self-confidence of the average man. The average man seeks certainty in the eyes of the onlooker and calls that self-confidence. The warrior seeks impeccability in his own eyes and calls that humbleness. Tales of Power - C. Castaneda
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk