Subject: [boost] [gsoc] Pointer Plus Bits Behavior and Interface
From: Brian Bartman (bbartmanboost_at_[hidden])
Date: 2010-07-15 10:17:48
Pointer Plus Bits: Is a data structure which points to specifically aligned
object such that the value of the address is divisible by a power of two
(the power of two which it is divisible by is given as a template argument).
The empty bits of the pointer are then used to store extra boolean values
relating to something (This is of the programmers choosing but it would seem
best practice to make it related to the object being pointed at). The
technique is of storing extra bits inside of pointers is some times referred
to as bit stuffing. Clang uses this technique for their QualType pointer:
So here are some of the questions I would like to pose to the community
about the behavior and interface of the pointer_plus_bits data structure:
1) Should the pointer_plus_bits have a pre and post increment and decrement
( what about supporting other arithmetic operations such as add, minus, add
assign etc...) ?
One could do this if the sizeof the type is evenly divisible by 2 to the
number of bits being "stuffed". The next/previous object in the array being
traversed could be correctly pointed at (assuming that the item being
pointed at IS an array).
1.a) If this is a behavior supported by the pointer_plus_bits should it keep
the bits being stuffed or set them to zero each time?
2) Should the bits being stuffed apply during comparison?
3) Should the pointer provide compatibility between itself and pointer of
the same type that is being stuffed (the behavior of this would mean masking
out the pointer so the stuffed bits won't apply during the comparison)? (ie
Should pointer_plus_bits<T,2> be comparable to T* ?)
(in pointer_plus_bits 2 is the number of bits being stuffed).
-- thanks, Brian Bartman
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk