problem compiling ublas vector iterator with templates

Hi, I'm trying to compile the following piece of code with gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu7) and I keep getting the error message listed below. A colleague of mine told me that he can compile it on MSVC. If I remove the template and set everything as vector<double> then it compiles without any problem. Anyone has an idea of what I may be doing wrong? Thanks, Alain <... bunch of include statements ...> namespace UBLAS = boost::numeric::ublas; //summation of a vector template <class Tv> Tv vectorSum(const UBLAS::vector< Tv >& A) { Tv sum = 0; for (UBLAS::vector< Tv >::const_iterator it = A.begin(); it!=A.end(); ++it) sum += (*it); return sum; } g++ -I. -I./vector testvector.cc In file included from testvector.cc:43: vector/TVector.h: In function 'Tv vectorSum(const boost::numeric::ublas::vector<Tv, boost::numeric::ublas::unbounded_array<T, std::allocator<_CharT> >
&)': vector/TVector.h:509: error: expected `;' before 'it' vector/TVector.h:509: error: 'it' was not declared in this scope

AMDG Alain Leblanc wrote:
I'm trying to compile the following piece of code with gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu7) and I keep getting the error message listed below. A colleague of mine told me that he can compile it on MSVC. If I remove the template and set everything as vector<double> then it compiles without any problem.
Anyone has an idea of what I may be doing wrong?
Yep. Try typename UBLAS::vector< Tv >::const_iterator In Christ, Steven Watanabe

It worked. Thanks for your help. a 2008/7/22 Steven Watanabe <watanabesj@gmail.com>:
AMDG
Alain Leblanc wrote:
I'm trying to compile the following piece of code with gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu7) and I keep getting the error message listed below. A colleague of mine told me that he can compile it on MSVC. If I remove the template and set everything as vector<double> then it compiles without any problem.
Anyone has an idea of what I may be doing wrong?
Yep. Try
typename UBLAS::vector< Tv >::const_iterator
In Christ, Steven Watanabe
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Alain Leblanc
-
Steven Watanabe