This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

error when passing iterator to template function


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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]