This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC 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]

[Q] template compile error


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]