Boost logo

Boost :

From: Gary Powell (Gary.Powell_at_[hidden])
Date: 2001-03-18 12:05:11


Every time I've had to deal with this problem it wasn't just 1 bit per data
entry but rather groups of related bits.

struct MyCountry {
   int numberOfTroops : 6;
   int NumberOfRoyalCouncilors : 3;
   int OccupiedByEnemy : 1;
   int KingIsAlive : 1;
  etc.

};

The problem comes that on some machines some of these fields cross word
boundaries and hence reordering the fields becomes critical for performance
and code size. In addition, for various architectures it becomes important
to use structs with fields that the total number of in use bits sums to
multiples of word bits, and preferably register size bits. Otherwise the in
memory data savings can be lost, and performance becomes abysmal.

The problem as I see it, is that it would be difficult to write a generic
library to look at the machine architecture and know how to reorder the
fields. C++ doesn't let us ask much about the hardware in a machine
independent way.

  -gary-

> Message: 8
> Date: Sat, 17 Mar 2001 20:05:38 -0000
> From: pinkfloydhomer_at_[hidden]
> Subject: Re: Compact Data
>
> --- In boost_at_y..., pinkfloydhomer_at_y... wrote:
> > I may be asking a stupid question here, and it might even be off
> > topic (it's becoming a bad habit), but here goes:
> >
> > Is there currently in standard C++ a structured way to represent
> data
> > compactly, other than the old C bitfields?
> >
>
>
> Not to be rude, but isn't anybody but me interested in this?
>


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