Boost logo

Boost :

From: Andy Little (andy_at_[hidden])
Date: 2005-10-21 03:48:19

"Pavel Vozenilek" wrote
> Reviews of binary int utility are needed. The tool is very small (but useful)
> and review should not take much of time. Both Scott Schurr and Matt Calabrese
> put quite a lot of effort into their work.
> Scott Schurr's version is in (file
> It can be used as:
> unsigned int regValue2 = binary_int<1000,1001,0011,0000>::value;

*** implementation

I expected the binary_int to be in boost namespace.

I would expect use of mpl maths on binary_int
    typedef boost::binary_int<0001> left;
    typedef boost::binary_int<0010> up;

    typedef mpl::or_<left,up> left_n_up;

I understand about use of enums, however they can cause problems in addition
where some compilers dont recognise e.g addition of two enums etc.

*** design

I would expect value_type to reflect the number of nibbles

    boost::binary_int<0000,0001> // unsigned char
    boost::binary_int<0000,0000,0001> // unsigned short or unsigned int
dependent on platform dependent type

Traditionally these types are regarded as unsigned are they not? Often they are
used for port flags which require a specific size which may be 8 bits and will
then require a downcast in some cases.

Should have the self 'type' member

Overall the use of nibbles I like. I find the comma separators between nibbles
good. Without them it is often difficult to find out where you are in a mask.
This is how I like to work when using bitmasks.

*** implementation

I didnt look closely.

*** documentation

I found it a bit sparse, because there are no operations etc. On structure I
believe that
the documentation should be separate from the utility stuff. Personally I think
separation of any stuff into utility is a bit arbitrary anyway as most of boost
libraries are utility . It is not the same as the usual boost format making
documentation for e.g enable_if hard to find.

*** Use the library?

I tried it out in VC7.1.No problems, but not much functionality... Lack of bost
namespace was unexpected. I thought this was a requirement on proposals?

** should it be a Boost library?

Yes, but only on condition that the library is much more fleshed out.

Overall I like the idea, but I dont think that it has been worked on enough yet.
It should have the masking operations. They should probably use the mpl

I also beleive that binary literals should be part of the languge anyway.

> Matt Calabrese's version is in
> It can be used as:
> int x = BOOST_BINARY_LITERAL( 101 0111 1010 0110 );

I prefer templates to macros. , so I prefer Scott Schurrs version. I
also happen to like the nibble separators. Also I would like a bit of separate

Andy Little

Boost list run by bdawes at, gregod at, cpdaniel at, john at