Inconsistent definition of vector<bool> specialization (again)

Arvid Bessen a_bessen@informatik.uni-kl.de
Sat Mar 10 06:27:00 GMT 2001


Benjamin Kosnik wrote:
> 
> can you please just post the code that is not working for you and the
> error you receive? I'm a bit confused as to what your problem is.
> 
> -benjamin
Okay, a little example:
// ---------------------------- two.hh ----------------------------
#include <vector.h>

class Example {
public:
	 vector<bool> vb;
	 Example();
};

// ---------------------------- two.cc ----------------------------
#include "two.hh"

Example::Example()
	 : vb()
{
	 // 'print vb' in gdb returns:
	 // $1 = {<_Vector_base<bool,allocator<bool> >> =
	 // {<_Vector_alloc_base<bool,allocator<bool>,>> = {_M_start
	 // = 0x0, _M_finish = 0x0,
	 // _M_end_of_storage = 0x0}, <No data fields>}, <No data 
	 // fields>}
}

// ---------------------------- one.cc ----------------------------
#include <vector>
#include "two.hh"

int main(int argc, char * argv[]) {
	 Example ex;
	 // 'print ex.vb' in gdb now returns:
	 // $2 = {<_Bvector_base<allocator<bool> >> =
  	 // {<_Bvector_alloc_base<allocator<bool>,>> = {_M_start =
	 // {<random_access_iterator<bool,int>> = {<No data fields>},
	 // _M_p = 0x0, _M_offset = 0},
	 // _M_finish = {<random_access_iterator<bool,int>> = {<No
	 // data fields>},
	 // _M_p = 0x401a1044, _M_offset = 1073792864},
	 // _M_end_of_storage = 0xbffffaf0}, <No data fields>}, <No
	 //  data fields>}
	 //
	 // and this prints 1087457664
	 cout << ex.vb.size() << endl;
}

// ----------------------------------------------------------------

When I compile two.cc, I don't use the specialization from
<stl_bvector.h> because I included <vector.h>.
In one.cc I included <vector> and the vector<bool> is treated as if it
were the specialized version.

Arvid



More information about the Libstdc++ mailing list