This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

problem with template parameter in g++ 4.4.1


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.


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