<Mi*************@tomtom.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
: Ivan Vecerina wrote:
: > "Piotr" <ra************@gmail.com> wrote in message
: > news:11**********************@f14g2000cwb.googlegr oups.com...
: > : In effective STL, it said one should not use vector<bool> but use
: > : dequeue<bool> instead....
: > is there another solution?
: >
: > Yet another alternative might be to store bools into a:
: > std::vector<unsigned char>
:
: The reason to avoid std::vector<bool> is because it doesn't contain
: genuine bools. If you can live with std::vector<unsigned char>, you
: definitely don't need genuine bools. So your replacement works only
: if it is not needed, sorry.
This seems like a very decisive all-encompassing statement.
I do not agree that 'needing references to bool elements'
is the only reason to avoid vector<bool>.
The requirement could be to 'store true/false values in a contiguous
array', and then deque<bool> won't do, but vector<uchar> might.
A trade-off does exist.
For example, I happen to use 'unsigned char' buffers to store
B/W 'binary' images - even when only a bool really is needed.
A contiguous buffer addressable with plain pointers facilitates
the implementation of image processing algorithms.
Peace,
Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Brainbench MVP for C++ <>
http://www.brainbench.com