关于vector的erase使用

CvSeqWriter writer1,writer2;
 CvMemStorage* storage1 = cvCreateMemStorage(0);
 CvMemStorage* storage2 = cvCreateMemStorage(0);
 CvSeq* point_seq1=cvCreateSeq( CV_32SC2, sizeof(CvSeq), sizeof(CvPoint), storage1 );
 CvSeq* point_seq2=cvCreateSeq( CV_32SC2, sizeof(CvSeq), sizeof(CvPoint), storage2 );
 cvStartAppendToSeq(point_seq1, &writer1 );
 cvStartAppendToSeq(point_seq2, &writer2 );
 CvPoint point1,point2;
 matchingslist::iterator ptr1 = matchings1.begin();
 for(i=0; i < (int) matchings1.size(); i++, ptr1++)
 {
  for (n=0;n<num_bins;n++)  
  {
   if ( bins_num1[n]<=2 &&ptr1->first.x>bins*n&&ptr1->first.x<=bins*(n+1) )
    ptr1=matchings1.erase(ptr1);  ///////神奇见证,仅matchings1.erase(ptr1); 会报错
   else
   {
    point1.x=ptr1->first.x;
    point1.y=ptr1->first.y;
    point2.x=ptr1->second.x;
    point2.y=ptr1->second.y;
    CV_WRITE_SEQ_ELEM(point1, writer1);
    CV_WRITE_SEQ_ELEM(point2, writer2);
    point2.x+=pFrame1->width+band_w;
    cvLine(matchedimg1, point1, point2, CV_RGB(255,0,0), 1, 8, 0 );
   }
  }
 }
 cvEndWriteSeq( &writer1);
 cvEndWriteSeq( &writer2);

你可能感兴趣的:(vector,iterator)