C++ STL vector<bool> et. al.

Kevin D. Clark kclark at elbrysnetworks.com
Thu Dec 14 16:19:44 EST 2006


Jerry Feldman <gaf at blu.org> writes:

> In the code I'm hacking they have a home grown boolean array. One example 
> is that it has a boolean array of business days, holidays and a few 
> others. Rather than use the existing class I am somewhat leaning toward 
> replacing the boolean array class with either std::vector<bool> or std::bitset. 
> Note that the original code I am porting contained its own string, array, 
> map and set classes, which I am replacing with either the STL or RogueWave 
> analogs to the STL. (What I'm doing is writing part of a new product, but 
> I need to preserve many of the classes.)

I'd recommend avoiding std::vector<bool> and using std::bitset or
deque<bool> instead.  std::vector<bool> isn't a true STL container,
and this might cause you some trouble.

Meyers' _Effective STL_ book discusses this in some detail.  Other
sources exist as well.

Regards,

--kevin
-- 
GnuPG ID: B280F24E              Never could stand that dog.
alumni.unh.edu!kdc                   -- Tom Waits


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.




More information about the Discuss mailing list