Stuck on compile error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm upgrading from gcc 2.96 to gcc 3.2.3, fixing
the various compiler warnings and errors in our
existing code base. One error has got me stumped.
Can anyone please tell me what's wrong with this?

I've boiled it down to its essential elements.


-------------

#include <vector>
using namespace std;

class ttiAucTriplet {

int i;
};

typedef vector<ttiAucTriplet> tVec;

void foo() {
    tVec tripletVec_;
    int numTriplets = 0;

    tripletVec_.erase(tripletVec_.begin(), &tripletVec_[numTriplets]); 
}


---------------
[root@ipc wgmm]# gcc foo.cpp
foo.cpp: In function `void foo()':
foo.cpp:15: no matching function for call to `std::vector<ttiAucTriplet,
   std::allocator<ttiAucTriplet> >::erase(
   __gnu_cxx::__normal_iterator<ttiAucTriplet*, std::vector<ttiAucTriplet,
   std::allocator<ttiAucTriplet> > >, ttiAucTriplet*)'
/usr/include/c++/3.2.3/bits/stl_vector.h:647: candidates are:
   __gnu_cxx::__normal_iterator<_Tp*, std::vector<_Tp, _Alloc> >
   std::vector<_Tp, _Alloc>::erase(__gnu_cxx::__normal_iterator<_Tp*,
   std::vector<_Tp, _Alloc> >) [with _Tp = ttiAucTriplet, _Alloc =
   std::allocator<ttiAucTriplet>]
/usr/include/c++/3.2.3/bits/stl_vector.h:670:
   __gnu_cxx::__normal_iterator<_Tp*, std::vector<_Tp, _Alloc> >
   std::vector<_Tp, _Alloc>::erase(__gnu_cxx::__normal_iterator<_Tp*,
   std::vector<_Tp, _Alloc> >, __gnu_cxx::__normal_iterator<_Tp*,
   std::vector<_Tp, _Alloc> >) [with _Tp = ttiAucTriplet, _Alloc =
   std::allocator<ttiAucTriplet>]


I suspect it has something to do with the return type.
vector::erase() actually returns an iterator, which
appears to be ignored here. I've tried assigning the 
return value of the function to a temporary iterator,
but that didn't seem to help any.

Thank in advance.

--
Gary Cote
gcote@xxxxxxxxxxxxxxxx 


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux