|
Boost : |
Subject: Re: [boost] [gsoc] Pointer Plus Bits Behavior and Interface
From: Andrew Sutton (andrew.n.sutton_at_[hidden])
Date: 2010-07-15 13:09:27
>
> > Would it be better to make the pointer_plus_bits convertible
> > to a boolean
> > based on the value of the pointer being stored? This would
> > allow it to be
> > more like to a pointer being that you could, as many people do, put it
> > inside of an if statement to check to see if its null.
>
> No. One could argue that the bits should be evaluated to produce the
> Boolean result as easily as evaluating the pointer. There are two aspects
> in pointer_plus_bits and they shouldn't be obscured or conflated.
>
I strongly disagree with using views in the design of this data structure.
It's not such a complex concept that you would need to explicitly decouple
its concerns via views. You end up designing a pointer+bits that can't be
used natively as a pointer or bits.
The data structure is pointer_(plus_bits). First and foremost, I would
expect its instances to model (at least some) Pointer semantics, which
includes "if(p)" and not "if(pointer_view<...>(p))". Dereferencing the
pointer returns the object being pointed at--although it could also return a
pair with the object and extra bits, which might be kind of neat.
Otherwise, I suspect that providing a small set of member functions to
interact with the bitfield would be perfectly acceptable.
Andrew Sutton
andrew.n.sutton_at_[hidden]
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk