Re: [Boost-bugs] [Boost C++ Libraries] #3123: Support for serializing shared_ptr to const types

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #3123: Support for serializing shared_ptr to const types
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-07-22 15:42:03

#3123: Support for serializing shared_ptr to const types
  Reporter: sohail | Owner: ramey
      Type: Bugs | Status: closed
 Milestone: Boost 1.40.0 | Component: serialization
   Version: Boost 1.39.0 | Severity: Regression
Resolution: invalid | Keywords:
Changes (by ramey):

  * status: new => closed
  * resolution: => invalid


 Looking at the diff, I would rather call this "serialization of shared_ptr
 to a const type".

 The subject if serialization of "const" members is addressed in general in
 the manual in the section

 From the documentation

 "Saving const members to an archive requires no special considerations.
 Loading const members can be addressed by using a const_cast:

     ar & const_cast<T &>(t);

 Note that this violates the spirit and intention of the const keyword.
 const members are intialized when a class instance is constructed and not
 changed thereafter. However, this may be most appropriate in many cases.
 Ultimately, it comes down to the question about what const means in the
 context of serialization. "

 Basically, "const" means the member isn't meant to be changeable. It would
 be in appropriate for the serialization library (or any other library) to
 violate the explicitly stated intention - especially without calling
 attention to that fact. It the developer want's to override the "const"
 the special case of serialization, he has the option of using const_cast
 to implement and document this desire.

 If this used to work, it was an oversight which has since been corrected.

 Robert Ramey

Ticket URL: <>
Boost C++ Libraries <>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:00 UTC