help with vector code

Benjamin Kosnik bkoz@redhat.com
Tue Dec 11 12:56:00 GMT 2001


This program gives:

// libstdc++/4456, libstdc++/4457, libstdc++/4458

#include <vector>

void test01()
{
  using namespace std;
  typedef int 	mask;
  typedef vector<mask> 		vector_type;

  const int max = 255;
  vector_type v_c[max];
  vector_type v_de[max];

  int i = 0;
  mask mask_test = static_cast<mask>(0);
  mask mask_is = static_cast<mask>(0);
#if 1
  vector_type::reference m = v_c[i];
  // mask& m = v_c[i];
  m = mask_is;
#else
  v_c[i] = mask_is;
#endif
}


int main()
{
  return 0;
}


gives:
vec_tester.cc: In function `void test01()':
vec_tester.cc:18: cannot convert `void test01()::vector_type' to `int'
in 
   converting


Ok, first of all, what's up with the error message here? Is it
truncated?

Second of all, isn't it vector_type::reference converting to same? What
am I missing here? I suspect it's simple, and I'm sorry for bugging
y'all.

 vector_type::reference m = v_c[i]; // 18
                          = vector::reference

Ack!

-benjamin





More information about the Libstdc++ mailing list