Boost logo

Boost :

From: me22 (me22.ca_at_[hidden])
Date: 2006-06-08 00:04:28


I've been working on Yuval's suggestion of (little|big|native)_endian
wrappers, but ran into a problem. On fundamental types, the wrapper
works fine, and Beman's integer_cover_operators made it easy to add
support for integer operations. ( However, why does
integer_cover_operators use operators<T> and not
operators2<T,IntegerType> ? I needed to change that to solve an
ambiguity error. )

The problem comes when wrapping my (newly reimplemented) exact type.
In that case, deriving the wrapper from integer_cover_operators adds 1
byte :
sizeof( long ) = 0x4
sizeof( boost::big_endian< long > ) = 0x4
sizeof( boost::exact<24> ) = 0x3
sizeof( boost::big_endian< boost::exact<24> > ) = 0x4

I could just have a get member function in the wrappers, but that
loses much of the elegance. Any suggestions for solving this?

~ Scott McMurray

P.S. exact came out quite nicely, imho:
CHAR_BIT*sizeof( boost::exact<24>[2] ) = 48
CHAR_BIT*sizeof( boost::exact<24,signed,16>[2] ) = 64
CHAR_BIT*sizeof( boost::exact<32,unsigned>[2] ) = 64
CHAR_BIT*sizeof( boost::exact<8,unsigned,16>[2] ) = 32
( std::numeric_limits< boost::exact<24> >::min() ) = -8388608
( std::numeric_limits< boost::exact<24> >::min()-1 ) = 8388607
( std::numeric_limits< boost::exact<24> >::max() ) = 8388607
( std::numeric_limits< boost::exact<24> >::max()+1 ) = -8388608
( std::numeric_limits< boost::exact<24,unsigned> >::min() ) = 0
( std::numeric_limits< boost::exact<24,unsigned> >::max() ) = 16777215


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