[phobos] phobos commit, revision 1740

Jonathan M Davis jmdavisprog at gmail.com
Fri Jul 9 14:19:53 PDT 2010


On Friday, July 09, 2010 12:04:37 Walter Bright wrote:
> Andrei Alexandrescu wrote:
> > On 07/09/2010 01:28 AM, Sean Kelly wrote:
> >> On Jul 8, 2010, at 10:25 PM, Jonathan M Davis wrote:
> >>>> Also added specialization of Array for bool that stores one bit
> >>>> per element.
> >>> 
> >>> _Please_ tell me that's optional in some manner. I don't know
> >>> _anyone_ who uses vector<bool>  in C++ _precisely_ because of this
> >>> optimization.
> >> 
> >> Looks like this optimization is largely invisible to the user, unlike
> >> vector<bool>, and intended largely for space saving.  If you want a
> >> plain old BitArray there's one in std.bitmanip.
> > 
> > Yah. The issues are subtle, I plan to write an entire article about them.
> 
> Yes, clearly there needs to be a hint in the documentation about this,
> otherwise everyone will just assume it is a clone of vector<bool>,
> problems and all.
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos

Well, unless they actually look at the source code (and most wouldn't, I would 
think), then they wouldn't have a clue that Array!bool was special. So, I think 
that it's more likely that they'd think that Array!bool worked like Array!int, 
Array!string, etc. then for them to think that it works like vector<bool>. 
Still, I'd expect that most who figured out that it was doing something special 
with 1 bit per element would think that it was problematic like vector<bool>. 
But regardless, it would be good if it were made clear what Array!bool is doing 
and why it's not a problem like vector<bool> is.

- Jonathan M Davis


More information about the phobos mailing list