[serialization] The famous non-const value trap
Hi Boosters, I had the compile time warning discussed here ( http://boost.2283326.n4.nabble.com/Serialization-C4308-warning-with-MSVC9-td...) 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#t... Oh, and please forgive me if the answer is *obvious* - just an intermediate programmer. Colin
cc caprani wrote:
Hi Boosters,
I had the compile time warning discussed here (http://boost.2283326.n4.nabble.com/Serialization-C4308-warning-with-MSVC9-td...) 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?
That would be a surprise to me
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#t...
It used to be an error - but now it's a warning. Robert Ramey
participants (2)
-
cc caprani
-
Robert Ramey