Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2008-08-06 00:51:40


Emil Dotchevski wrote:
> On Tue, Aug 5, 2008 at 5:05 PM, Robert Ramey <ramey_at_[hidden]> wrote:
>> Emil Dotchevski wrote:
>>> it a good idea for the shared_ptr
>>> serialization to be implemented in terms of the T * object contained
>>> in a boost::shared_ptr<T>?
>>
>> The current implementation of serialization of boost::shared_ptr
>> depends only upon the published public interface of
>> boost::shared_ptr. (personally I have some complaints about that
>> public interface though). Assuming that std::shared_ptr has the same
>> published interface
>> as boost::shared_ptr - I would expect the serialization implemenation
>> would be the same.
>
> Then maybe I misunderstood your earlier reply, that
> boost::shared_ptr<std::string> can't be serialized directly because it
> contains a std::string pointer. That's why I brought up the pointer
> stored in std::string, which is an implementation detail indeed, as is
> the T pointer in boost::shared_ptr<T>.
>
> So, why wouldn't shared_ptr<std::string> "just work" when serialized,
> even if serializing std::string raw pointers doesn't?

well, I suppose it could be "made to work" by internally wrapping
it in a special type so it doesn't get treated as a serialization primitive.
I would never occur to me to do such a thing though. The strength
of the current approach is it's "conceptual integrity". That is
shared_ptr<T> is pointer is serializable if and only if T * is serializable.
This is much simpler than trying to out smart the programmer by
silently fixing things up for him when it can.

Robert Ramey

>
> Emil Dotchevski
> Reverge Studios, Inc.
> http://www.revergestudios.com/reblog/index.php?n=ReCode


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