Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2003-11-17 21:59:06


>> 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]);
    }
};

loading array code is found in iserializer.hpp

Robert Ramey


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