|
Boost : |
From: Emile Cormier (emilecormier_at_[hidden])
Date: 2006-03-08 19:12:18
Bitfield2.zip in
http://boost-consulting.com/vault/index.php?direction=0&order=&directory=bitfield&
For now, I didn't bother to adapt my code to Boost's style. I'm using
this stuff at work where we have a different coding style. Check out the
html folder for the doxygen page, which shows usage examples.
I removed Bitfield::operator(), as its purpose was not self-evident.
I think this version will not suffer from memory alignment/padding
problems as did the previous version. The test code runs fine with GCC
MinGW 3.4. I plan on using it on an ARM platform, so I'll confirm if it
runs okay on that platform too.
Bitfield now accepts a 4th template parameter, R, which is the reference
type used by Bitfield to manipulate the word. The only requirements on
this reference type are:
- Has a default or copy constructor, depending on how you use it
- Can be assigned a value of type T
- Can be evaluated as a value of type T
By default, R=T&, which is convenient for manipulating regular
non-I/O-mapped integers.
I demonstrate in PortExample.hpp how Bitfield can be used with special
types which can interface to memory-mapped I/O ports. I've just read the
n1666 "Technical Report on C++ Performance", and it seems like Bitfield
would be ready to support the use of <iohw.h> ports. I need to study the
proposed <iohw.h> some more to fully understand it, though.
I will inspect mixed source+assembly to confirm that this Bitfield
mechanism is as efficient as hand-written bit-manipulations.
-- Emile Cormier emilecormier_at_[hidden]
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk