Boost logo

Boost :

From: Matthias Troyer (troyer_at_[hidden])
Date: 2003-11-18 03:20:30


On Nov 18, 2003, at 3:59 AM, Robert Ramey wrote:

>>> Matthias Troyer wrote:
>>>> * add a default implementation that just calls the serialization
>>>> function for each element consecutively. Then only those archives
>>>> for
>>>> which the fast implementation are necessary and/or possible have to
>>>> implement the array version.
>>>
>>> The current implemenation already has this.
>
>> Sorry, I could not find it. Can you point me to some header file or
>> manual section?
>
> The manual includes a section titled "Serialization Implementations
> Included in the Library"
> which touches upon this. The code that implements it can be found in
> header file oserializer.hpp:
>
> struct save_array_type
> {
> static void invoke(Archive &ar, const T &t){
> // consider alignment
> int count = sizeof(t) / (
> static_cast<const char *>(static_cast<const void *>(&t[1]))
> - static_cast<const char *>(static_cast<const void
> *>(&t[0]))
> );
> ar << BOOST_SERIALIZATION_NVP(count);
> int i;
> for(i = 0; i < count; ++i)
> ar << make_nvp("item", t[i]);
> }
> };

Sorry, but if I am not mistaken, I do not see how this can work with
the following array

double* p=new double[n];

since sizeof(p) is just 4 or 8 bytes and sizeof(*p) would be 8 bytes.
You would have to pass the size of the array n as a second argument.

Matthias


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk