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]

GCC FAIL WITH BASIC STL EXAMPLE


Hello Guys,

I am developing some applications that extensively uses STL. I plan to use
the
traits -> iterator_traits to get information about which type do I need to
return.
Unfortunately, I've been experienced some problems to use such
functionality.

This simple test code was extracted from the SGI-STL website, but oddly
enough it doesn't compile:
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>

template <class InputIterator>
std::iterator_traits<InputIterator>::value_type
last_value(InputIterator first, InputIterator last) {
std::iterator_traits<InputIterator>::value_type result = *first;
for (++first; first != last; ++first)
result = *first;
return result;
}

using namespace std;

int main()
{
std::vector<double> teste(10);
fill_n(teste.begin(),10,1.2);
double result = last_value(teste.begin(),teste.end());
return 0;
}

The error response is:
argdeduction.cpp:8: error: expected constructor, destructor, or type
conversion before âlast_valueâ
argdeduction.cpp: In function âint main()â:
argdeduction.cpp:21: error: âlast_valueâ was not declared in this scope

Hopefully,
Trincheira
--
View this message in context: http://www.nabble.com/GCC-FAIL-WITH-BASIC-STL-EXAMPLE-t1539525.html#a4182440
Sent from the gcc - libstdc++ forum at Nabble.com.


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