This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: error when passing iterator to template function
- From: plt <freeplant at gmail dot com>
- To: libstdc++ at gcc dot gnu dot org
- Date: Thu, 20 Apr 2006 08:51:27 +0800
- Subject: Re: error when passing iterator to template function
use
one<int>(v.begin());
instead.
I find it can work on g++ 4.1.0, Fedora 5
I think the problem is that we should tell the compiler more
information.
On Wed, 2006-04-19 at 11:25 -0700, Daniel Pape wrote:
> 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
>