I don't know how many people know this but a vector of bools is not a container. (see this: http://www.gotw.ca/publications/mill09.htm for more info)

I have a template'd function that works for everything except a vector of bools (again read the article to see why).

Code:

//My function is essentially like this
template<class T>
void f( T& t )
{
//Neither of these two statements work with bool
typename T::value_type* p1 = &t[0];
typename T::value_type* p2 = &*t.begin();
// ... do something with *p1 and *p2 ...
}

So my question is: what's the best way to get the data from a vector of bools? Is the only way to loop through it and do it one item at a time?

I tried:

#define STD_VECTOR_BOOL_NOT_SPECIAL

but that didn't do anything (using g++ 3.4.5).