Boost logo

Boost :

From: Scott McMurray (me22.ca+boost_at_[hidden])
Date: 2008-05-24 11:23:11


On Sat, May 24, 2008 at 7:45 AM, Beman Dawes <bdawes_at_[hidden]> wrote:
> Neil Mayhew wrote:
>> The areas that I am interested in seeing more work done on are (1)
>> making constructors "conditional" and (2) adding a bit-range access method.
>
> Do you have a proposed design for bit-range access?
>
> What is the use case or motivation for bit-range access?
>

Perhaps something based off of erlang's Bit Syntax?
http://www.erlang.org/doc/reference_manual/expressions.html#6.16

Armstrong's Erlang book gives MPEG headers as an example of bit range
access, among other things.

So something like

typedef bit_sequence<
    uint_t<11>,
    uint_t<2>,
    uint_t<2>,
    uint_t<1>,
    uint_t<4>,
    uint_t<2>,
    uint_t<1>,
    uint_t<9>
> MPEG_header;

Or if you're writing a linker to generate EXEs for windows (another
example from Armstrong's book),

typedef bit_sequence<
    little_endian< uint_t<32> >, // Characteristics
    little_endian< uint_t<32> >, // TimeDateStamp
    little_endian< uint_t<16> >, // MajorVersion
    little_endian< uint_t<16> >, // MinorVersion
    little_endian< uint_t<16> >, // NumberOfNamedEntries
    little_endian< uint_t<16> > // NumberOfIdEntries
> image_resource_directory;

Be fun to be able to get everything as a tuple, too, to be able to
assign to a tie, pattern-matching style

That interface works better for the bit ranges, though, I suppose,
since little_endian< uint_t<32> > as a boost.endian type on its own
would be far more convenient name-wise than having to get it through a
tuple-style interface.

Just thinking out loud,
~ Scott


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