Boost logo

Boost Users :

Subject: [Boost-users] [serialization] The famous non-const value trap
From: cc caprani (cc.caprani_at_[hidden])
Date: 2011-08-25 20:45:02


Hi Boosters,

I had the compile time warning discussed here (
http://boost.2283326.n4.nabble.com/Serialization-C4308-warning-with-MSVC9-td2600175.html)
that Robert is probably fed up discussing. I've read for months, but didn't
want to const_cast my object (or is it ok sometimes?). However, making my
destructor virtual removed the warning. Here's my question: why does making
the object destructor virtual remove the warning, effectively making my
object instances const?

And the section on this trap from the Rationale section of the Serialization
documentation is not in the1.47 version (howcome?) but can be found in
previous version here:
http://www.boost.org/doc/libs/1_39_0/libs/serialization/doc/rationale.html#trap

Oh, and please forgive me if the answer is *obvious* - just an intermediate
programmer.

Colin



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net