This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
[Q] template compile error
- From: Moon Hwang <moon dot hwang at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 21 Oct 2005 11:54:48 -0700
- Subject: [Q] template compile error
- References: <7adf9af0510211135m790caebap@mail.gmail.com>
I entered following template compile error when using gcc version 3.4.4.
=============== test.cpp source code =====================
#include <list>
template <class _T>
std::list<_T> shallow_copy(const std::list<_T>& original)
{
std::list<_T> tmp;
std::list<_T>::const_iterator it = original.begin();
for(; it != original.end(); it++) {
tmp.push_back(*it);
}
return tmp;
}
=========================================================
> gcc test.cpp -c
test.cpp: In function `std::list<_T, std::allocator<_CharT> >
shallow_copy(const std::list<_T, std::allocator<_CharT> >&)':
test.cpp:7: error: expected `;' before "it"
test.cpp:8: error: `it' undeclared (first use this function)
test.cpp:8: error: (Each undeclared identifier is reported only once
for each function it appears in.)
=============================================================
But when using gcc 2.96, there is no error.
Is there any body can fix it?
MoonHo