|
Boost : |
Subject: Re: [boost] [Serialization]#3118 basic_binary_oarchive.hpp - save_override possible loss of data warnings
From: Chris Hamilton (chamilton_at_[hidden])
Date: 2009-06-01 11:43:27
> This would only be an issue in following cases:
>
> a) A class has more than 255 backward compatible versions.
> b) An archive has more than 64K different classes in it.
>
> It is currently inconcievable to me that such a program
> would ever be written. Setting the sizes of these
> types to larger values would make every single binary
> archive bigger and slower.
>
> The only think I might suggest is that one add an
> assertion so that if either of the above were to occur,
> the program would trap - at least in debug mode. So
> maybe one might use
>
> assert(t.t < max_value<unsigned char>
>> const unsigned char x = static_cast<unsigned char>(t.t);
>
> assert(t.t < max_value<int_least16_t >
>> const int_least16_t x = static_cast<int_least16_t>(t.t);
>
> Robert Ramey
You could always do some kind of escaped encoding. For example, reserve
a value of 255 to mean >=255, and follow that byte with the actual value
using a larger represention (may as well go right to a native int).
Cheers,
Chris
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk