Boost logo

Boost Users :

Subject: Re: [Boost-users] Serialization with pointer to const object
From: Soumen (soumen78_at_[hidden])
Date: 2009-07-31 05:58:41


Hi Robert,

I guess there's no direct way through which I can throw away const-ness
during serialization. One way is to modify my class to remove const-ness for
the pointee or use some temporary var which is non-const and serialize using
that. Right? Or is there a better way - in that case I'll follow that till
the issue gets resolved, hopefully, in boost.

Regards,
~ Soumen

Robert Ramey wrote:
>
> The question is under consideration. It won't be resolved for a while.
> And
> such resolution might or might not mean a change. To get over the hump,
> you
> might want to
> just use a const_cast.
>
> Robert Ramey
>
> Soumen wrote:
>> So finally to summarize it means that for now I cannot serialize
>> pointers to const obj. And I need to update my code to throw away the
>> const. Is that correct?
>>
>> Regards,
>> ~ Soumen
>>
>>
>> Sohail Somani-2 wrote:
>>>
>>> Emil Dotchevski wrote:
>>>> On Fri, Jul 24, 2009 at 8:06 PM, Robert Ramey<ramey_at_[hidden]> wrote:
>>>>> Emil Dotchevski wrote:
>>>>>> On Fri, Jul 24, 2009 at 4:40 PM, Robert Ramey<ramey_at_[hidden]>
>>>>>> wrote:
>>>>> would be equivalent to
>>>>> ar >> *m_x
>>>>> in which case the "const" would be violated.
>>>>
>>>> At the time the object needs to be instantiated and read, instead of
>>>> dealing with a T const * p as:
>>>>
>>>> p=new T;
>>>> ar >> *p;
>>>>
>>>> what's wrong with:
>>>>
>>>> T * tmp=new T;
>>>> ar >> * tmp;
>>>> p=tmp;
>>>
>>> This reminded me of the same issue with shared_ptr<const T>
>>> https://svn.boost.org/trac/boost/ticket/3123
>>>
>>> I'm not sure Robert is applying const correctness correctly here.
>>>
>>> There is no "const violation" here. If there was, you'd see a
>>> const_cast in the patch somewhere.
>>>
>>> --
>>> Sohail Somani
>>> http://uint32t.blogspot.com
>>>
>>> _______________________________________________
>>> Boost-users mailing list
>>> Boost-users_at_[hidden]
>>> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>

-- 
View this message in context: http://www.nabble.com/Serialization-with-pointer-to-const-object-tp24639258p24753924.html
Sent from the Boost - Users mailing list archive at Nabble.com.

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