Boost logo

Boost :

From: Darren Cook (darren_at_[hidden])
Date: 2004-09-28 19:10:54


>>class Example{
>>int str[BSize];
>>int *p;
>>};
> ....
> Or you might try the following (non-portable) idea
>
> ar & BOOST_SERIALIZATION_NVP(
> make_binary_object(str, (p - str)* sizeof(int))
> );

Thanks, that is closest to what I was after; I don't need a portable version
here.

> But really, I think you might be best off replacing the class above with
>
> class Example {
> std::slist<int> str; // or maybe std::vector<int> str }

It was done using a fixed size buffer to avoid dynamic memory allocation
(mainly for speed reasons). Serializing is relatively rare, but when it
happens there will be a very large number of objects so I didn't want the
full BSize elements stored.

However as I worked through the class some more I found it can output a
string representation, which uses fewer bytes. So in future I might add a
parser for input and then switch to using that (though I'll be back to
needing separate load/save functions then won't I, oh well :-).

Darren


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