error when passing iterator to template function

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

 



Hi -

I'm using "g++ (GCC) 3.4.5 20051201 (Red Hat 3.4.5-2)"

I suspect I'm doing something wrong, and I'm sure this is a FAQ, but a
few hours of reading and googling has not turned anything up.

I'm simply trying to pass an iterator to a template function. Here is
a simplified example that still has the error I'm seeing. I get
(approximately) the same error with g++ 3.2.3, 3.3.6 and 3.4.5

---------------
#include <vector>

template <class T>
void one(typename std::vector<T>::iterator it)
{
   (*it)++;
}

int main(int ac, char **av)
{
   std::vector<int> v(10);
   one(v.begin());
   return 0;
}
---------------

> g++ test.cpp
test.cpp: In function `int main(int, char**)':
test.cpp:12: error: no matching function for call to
`one(__gnu_cxx::__normal_iterator<int*, std::vector<int,
std::allocator<int> > >)'


Any help would be appreciated.

thanks,
Dan


[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