GCC FAIL WITH BASIC STL EXAMPLE

Jonathan Wakely jwakely.gcc@gmail.com
Tue May 2 16:50:00 GMT 2006


On 02/05/06, trincheira <trincheira@hotmail.com> wrote:
>
> Hello Guys,
>
> This simple test code was extracted from the SGI-STL website, but oddly
> enough it doesn't compile:

The example code is invalid, see below. When the example was written
very few compilers diagnosed the problem, so it worked on most (maybe
all) compilers available at the time.

> #include <iostream>
> #include <vector>
> #include <iterator>
> #include <algorithm>
>
> template <class InputIterator>
> std::iterator_traits<InputIterator>::value_type

need typename at start of line above

> last_value(InputIterator first, InputIterator last) {
> std::iterator_traits<InputIterator>::value_type result = *first;

need typename at start of line above

> for (++first; first != last; ++first)
> result = *first;
> return result;
> }
>



More information about the Libstdc++ mailing list