Boost logo

Boost :

From: Beman Dawes (beman_at_[hidden])
Date: 2000-11-18 08:01:23


At 07:56 PM 11/17/2000 -0700, Victor A. Wagner, Jr. wrote:

>I think that the entire C++ stream mechanism should be extended to
>'binary' or if you prefer, non-character-formatted streams. That this
was
>overlooked seems like a HUGE hole in the design. Then we could use the
>normal (overloaded "<<" and ">>" operators). Further, rather than
worrying
>about big/little endian in everyone's program, perhaps we should define a

>further mechanism which standardizes on the byte ordering in the file.

It isn't quite that simple. Some applications use big-endian, and
little-endian all in the same stream. Probably native too. Messy, but
that's the real world. Furthermore there is the issue of external
representation size. True you could supply formatters, but that starts to
get messy.

Safety is also an issue. I would like to see unsafe code fail loudly at
compile time rather than silently at runtime. For example:

     int i;
     my_stream >> big_end >> bytes(4) >> i;

This code will fail silently (because int is only 16-bits on some systems -
i should have been long or int_least32_t ), unless the implementation does
a lot of error checking. Between the messiness caused by the need for
formatters and the error detection issues, I not entirely convinced a
stream based approach is the way to go.

--Beman


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