Boost logo

Boost Announcement :

From: Pavel Vozenilek (pavel_vozenilek_at_[hidden])
Date: 2005-10-13 15:52:11

Review of binary_int utility written by Scott Schurr
begins today and lasts for 7 days.

The utility can be found at
file (8 kB).


The class template binary_int allows binary literals to be used
at compile time. The template reads a binary literal value comprised
of from 1 to 16 comma separated 4-bit units of ones and zeros.

Example of use:
#include <boost/utility.hpp>

unsigned int regValue2 = binary_int<1000,1001,0011,0000>::value;

enum {
    val1 = binary_int<1100,0010>::value,
    val2 = binary_int<1100,0011>::value

switch (x) {
    case binary_int<0110,0001>::value: ... break;
    case binary_int<0111,0001>::value: ... break;

===Alternative implementation===

Matt Calabrese had written alternative, using only preprocessor.

It can be found at

Example of use:
BOOST_BINARY_LITERAL( 101 0111 1010 0110 )

(there is no need for ::value, more on

===Open questions in Scott Schurs's library===

* How does it work on 64 bit systems? Could someone try?
* Naming: perhaps shorter names could be used (e.g. bits/nibble)
* BOOST_WORKAROUND in the code, is it really needed?

=== Questions for the reviewers===

* Which one of the alternatives fits in Boost better?
* What is your evaluation of the implementation(s)?
* Do you think the utility should be accepted as a Boost library?


Boost-announce list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at