public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* RE: Stuck on compile error
@ 2004-01-16 23:39 lrtaylor
  0 siblings, 0 replies; 2+ messages in thread
From: lrtaylor @ 2004-01-16 23:39 UTC (permalink / raw)
  To: gcote, gcc-help

If believe the problem is that erase expects two iterators, saying where to erase from and to.  The expression "&tripletVec_[numTriplets]" does not return an iterator, but the element stored at numTriplets.  So, it's a type mismatch.

Cheers,
Lyle


-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org]On
Behalf Of Gary Cote
Sent: Friday, January 16, 2004 4:08 PM
To: gcc-help@gcc.gnu.org
Subject: Stuck on compile error



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]); 
}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Stuck on compile error
@ 2004-01-16 23:08 Gary Cote
  0 siblings, 0 replies; 2+ messages in thread
From: Gary Cote @ 2004-01-16 23:08 UTC (permalink / raw)
  To: gcc-help


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@transat-tech.com 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-01-16 23:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-16 23:39 Stuck on compile error lrtaylor
  -- strict thread matches above, loose matches on Subject: below --
2004-01-16 23:08 Gary Cote

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).