Boost logo

Boost Users :

From: Andrea Denzler (andrea_at_[hidden])
Date: 2008-09-02 14:00:08


Since we like to add wood to the fire....

I think that the main problem of the serialization issues are due to the
fact that we use incompatible cross platform datatypes in our code. If int
is 32 bit in one system and 64 bit in another system then of course we run
into issues. The existing workarounds will work, but they may give failures
on other/new systems. What if int is 128bit or 16bit? The starting point of
using incompatible data types is wrong.

Using internal compatible datatypes is the first issue to solve, instead of
defining something like

int foo;

It is better if we can use something like:

int<min_value,max_value> foo;

On different platforms it will lead to different native c++ types, but I
don't care about. I want to be sure to have my range of values for foo.

In that case serialization is relatively easy to solve. I may would add some
minor options like performance versus low data size for a specific
serialization. Sometimes I need fast code, other times I need a low data
size. But this is just a extra option.

The same should be used for floating point values, something like

double<precision_digits,exponent_digits> foo;

I define how many digits I need and want. When using foo I know the minimum
precision available, maybe the c++ floating point type used has a greater
precision, but I don't care about.
Again when serializing I know how many digits are necessary, and probably
the IEEE standard of the two integers is the best to use. But this a choice
of the library write. I want a full portabile datatype/archive where a
specific number of digits are guaranteed in any operation (+, -, power,
serialization, etc).

Of course an exception is thrown at compile time if the specific
platform/library can't handle such requirements of example int<0,2^500> foo.

IMHO... :)

Andrea


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