[Q] template compile error

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

 



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 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