I work on a library compiled with gcc4.0 and old versions. I want to insert OpenMP directives in the source code. So I compiled the code with gcc4.4 version since openmp is recognized that from version 4.2, but I get many errors especially at the Definiton of templates. So I want to know what is the difference between these versions of gcc and is there a way that ensures the porting of programs compiled with older versions to newer versions of gcc. Here it below some of the code and the errors obtained in compilation.
ifndef _PAT_FAM #define _PAT_FAM #include <iostream> #include <vector> template<typename P, template<typename T> class ST> class pat_fam; template<typename P, template<typename T> class ST> std::ostream& operator<< (std::ostream&, const pat_fam<P, ST>&); template<typename P, template<typename T> class ST=std::vector> class pat_fam: public ST<P*> { public: typedef typename ST<P*>::iterator IT; typedef typename ST<P*>::const_iterator CONST_IT; friend std::ostream& operator<< <>(std::ostream&, const pat_fam<P, ST>&); }; template<class P> std::ostream& operator<< (std::ostream& ostr, const pat_fam<P, std::vector>& pats) { typename pat_fam<P, std::vector>::CONST_IT it; for(it=pats.begin(); it!=pats.end(); it++) ostr<<*it<<std::endl; return ostr; } #endif pat_fam.h:57: erreur: type/value mismatch at argument 2 in template parameter list for ‘template<class P, template<class T> class ST> class pat_fam’ pat_fam.h:57: erreur: expected a template of type ‘template<class T> class ST’, got ‘template<class _Tp, class _Alloc> class std::vector’ pat_fam.h: In function ‘std::ostream& operator<<(std::ostream&, const int&)’: pat_fam.h:59: erreur: type/value mismatch at argument 2 in template parameter list for ‘template<class P, template<class T> class ST> class pat_fam’ pat_fam.h:59: erreur: expected a template of type ‘template<class T> class ST’, got ‘template<class _Tp, class _Alloc> class std::vector’ pat_fam.h:59: erreur: invalid type in declaration before ‘;’ token pat_fam.h:60: erreur: request for member ‘begin’ in ‘pats’, which is of non-class type ‘const int’ pat_fam.h:60: erreur: request for member ‘end’ in ‘pats’, which is of non-class type ‘const int’ pat_fam.h:61: erreur: invalid type argument of ‘unary *’ The same code compiles without error with g++3.4 Thanks a lot. -- View this message in context: http://old.nabble.com/problem-with-template-parameter-in-g%2B%2B-4.4.1-tp27784556p27784556.html Sent from the gcc - bugs mailing list archive at Nabble.com.