How to declare a vector<vector<bool> > verified as false?

Hi,

I want to create a matrix

vector<vector<bool> > verified(m.getcols(), vector<double>(m.getlines()));

How to set all positions to false? (I intent not to use loops)

Is there a way?
 
vector< vector< bool > > verified( cols, vector<bool>( rows, false ) );

Are they not initialized to false automatically? Or are you asking how to reset them after the container has already been changed? By the way, I have never used vector<bool> and due to it being a template specialization and not a real STL container, I'm not sure if it can support multiple dimensions. take a look at this.
http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=98

I've always been advised to completely avoid vector<bool> I have never seen anyone attempt to build a 2D array with it. Good luck!

Even if you are able to do 2D arrays you'll have a difficult time avoiding for loops when you want to reinitialize it. It is really difficult to find information on this container since it is so rarely used. Since it's underlying memory isn't guaranteed to be contiguous you can't use it like other vectors. You really have to understand a lot about the implementation to fully appreciate the dangers of this container. You might have to read the C++ std to understand what you can do with this class because I have not been able to find books or examples that explain how to use this container effectively. Much of what I have read is that we should avoid it.
Topic archived. No new replies allowed.