Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2008-08-30 01:12:22


I'm suspecting that there is a confusion about how to seriailzation a
pointer to
a null terminated string. It's natural to want to do something like

char *p;
...
p = "jsdkfjads"
...
ar & p;

because the library syntax encourages one to think that way.

But in this case, one would want

save(...
    int i = strlen(p);
    ar << i;
    ar << binary_object(i, p);
}

load(...
    int i;
    ar >> i;
    ar >> binary_object(i,p);
}

That is, I think the question reflects a mis-conception
about the best way to use the library.

Robert Ramey

Matthias Troyer wrote:
> How would you serialize pointers as binary objects?
>
> On 29 Aug 2008, at 17:13, Robert Ramey wrote:
>
>> Are you sure really want to do this? look into binary object.
>>
>> Robert Ramey
>>
>> Matthias Troyer wrote:
>>> On 28 Aug 2008, at 20:47, Diane wrote:
>>>> tracked_char *tcp = it.chstar; //****error on this line****//
>>>> ar & *tcp;
>>>> }
>>>>
>>>> I get this compile error: cannot convert `char*' to `tracked_char*'
>>>> in initialization
>>>
>>> Can you try
>>>
>>> tracked_char* tcp(it.chstar)
>>>
>>> That sometimes works for me if I have such problems
>>>
>>> Matthias
>>
>>
>>
>> _______________________________________________
>> Boost-users mailing list
>> Boost-users_at_[hidden]
>> http://lists.boost.org/mailman/listinfo.cgi/boost-users


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