|
Boost : |
From: Jens Maurer (jmaurer_at_[hidden])
Date: 1999-08-18 16:11:22
A few general comments on bin_ubin.hpp:
This is intended to be a representation for portable integers.
However, there is no way to access the portable representation.
I could use memcpy(), but this is ugly and not portable,
because the layout of struct members in general is not
defined. I therefore suggest member functions
void write(ostream &);
and
void read(istream &);
and probably a constructor
binXX(istream &);
Member variable identifiers start with an underscore, although
these identifiers are reserved for the C++ implementation.
In general, I wonder why there are separate classes binXX
instead of (specializations of)
template<int n> class bin { ... };
This would even allow for a generic implementation using
a C-array instead of separate char member variables.
And the C-array solves all troubles with struct layout,
because (I think) C-arrays are supposed to have a compact
memory layout. If we don't trust the compiler, we can
unroll the resulting loop with template techniques.
Beman Dawes wrote:
> * As an implementation artifact unrelated to the specification,
> <boost/stdint.h> and thus <boost/cstdint.hpp> #include <limits.h>.
> This allows an implementation portable to many (most?) modern
> computer systems, but has the side effect of defining a bunch of
> macros (xxx_MAX/xxx_MIN/etc). Should these be #undef'ed at the end
> of boost/stdint.h?
If some program actually needs these macros, probably for backward
compatibility, and we have something like
#include <limits.h>
#include <boost/cstdint.hpp>
the programmer would be surprised to find the macros undefined.
> * What compilers does
> http://www.boost.org/libs/integer/bin_ubin_test.cpp work with? It is
> already known to work with Metrowerks and Microsoft compilers. It
> doesn't work with gcc 2.95 - are there any egcs experts out there
> that can provide insight?
It works with a slightly more recent CVS checkout of gcc/egcs.
After fixing the line-ending trouble with smart_ptr (see other
mails on that subject), I had to add "boost::" in front of int32_t
in line 109 of bin_ubin_test.cpp. Yes, I know we have a "using
namespace boost" before.
And, bin_ubin_test.cpp needs "#include <cstdlib>" for std::atol().
Jens Maurer
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk