List:MySQL++« Previous MessageNext Message »
From:Warren Young Date:May 3 2005 11:29pm
Subject:Re: equal_list() using a bool vector
View as plain text  
Mark Merendino wrote:

> Im trying to use the equal_list() method and passing a vector to it.
> such as in the example from the manual...

I see you're still using the old manuals.  I elided that stuff when 
moving it over to the new structure, in the name of simplicity.  It 
seemed like a case of someone who was too close to the library 
documenting internals when they should have kept quiet about it.

I suggest one of two things: a) we figure out how this feature is 
supposed to work, and document it toward the end of the existing SSQLS 
section of the user manual; or b) we keep it as it is: an internal 
feature mentioned only in the reference manual.

> 	vector<bool> a;    
> 	a[0] = false; a[1] = false; a[2] = true; a[3] = true; a[4] =
> false;   

You're skating on thin ice with that technique.  Subscripting a vector 
doesn't expand it.  Since you haven't reserve()d any space in the 
vector, you're depending on the implementation to preallocate some for 
you.  It happens that you usually get 10 or so slots at the start with 
the STL implementations I'm familiar with, but it's bad form to depend 
on them being there.

The simplest safe code is:

	vector<bool> a(5, false);
	a[2] = true;
	a[3] = true;
Thread
equal_list() using a bool vectorMark Merendino3 May
  • Re: equal_list() using a bool vectorChris Frey4 May
  • Re: equal_list() using a bool vectorWarren Young4 May
RE: equal_list() using a bool vectorMark Merendino5 May
  • Re: equal_list() using a bool vectorWarren Young10 May
    • [PATCH] Re: equal_list() using a bool vectorChris Frey10 May
      • Re: [PATCH] Re: equal_list() using a bool vectorWarren Young10 May
        • Re: [PATCH] Re: equal_list() using a bool vectorChris Frey10 May
          • Re: [PATCH] Re: equal_list() using a bool vectorWarren Young11 May
RE: [PATCH] Re: equal_list() using a bool vectorMark Merendino11 May
  • Re: [PATCH] Re: equal_list() using a bool vectorChris Frey11 May
    • Re: [PATCH] Re: equal_list() using a bool vectorWarren Young11 May