Subject: Re: [Boost-bugs] [Boost C++ Libraries] #8157: Access violation of const objects
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-02-25 20:13:34
#8157: Access violation of const objects
---------------------------------------------------+------------------------
Reporter: MichaÅ KÄdrzyÅski <kedrzu@â¦> | Owner: ramey
Type: Bugs | Status: new
Milestone: To Be Determined | Component: serialization
Version: Boost 1.52.0 | Severity: Problem
Resolution: | Keywords: const
---------------------------------------------------+------------------------
Comment (by MichaÅ KÄdrzyÅski <kedrzu@â¦>):
Replying to [comment:1 ramey]:
> value change ONLY when being saved. You example only shows saving.
Perhaps you might want to test loading into a const object? Note that
saving REQUIRES a const object for reasons described in the documentation
This is of course true, but according to the concept of constant values,
this should also not happen. User should expect, that object is not
changing, no matter what actions are being done. This is what i meant
saying about unexpected behaviour.
Serialize method could be declared as const:
{{{
template<class Archive>
void serialize(Archive & ar, const unsigned int version) const
{
ar & degrees;
ar & minutes;
ar & seconds;
++degrees;
++minutes;
++seconds;
}
}}}
Therfore this program would not compile. Forcing user to declare serialize
method as const would prohibit such a bahaviour without any further
changes.
Note, that when you split serialize into save/load methods, save method
must be declared const for program to be compiled. Thus standalone
serialize method should also be const, as it is responsible for saving as
well as loading.
I am aware, that this is quite big change, as it would change the use of
library.
MichaÅ KÄdrzyÅski
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/8157#comment:2> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:12 UTC