public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* problem with template parameter in g++ 4.4.1
@ 2010-03-04 18:16 hannibal81
2010-03-04 20:19 ` Andrew Pinski
0 siblings, 1 reply; 2+ messages in thread
From: hannibal81 @ 2010-03-04 18:16 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: problem with template parameter in g++ 4.4.1
2010-03-04 18:16 problem with template parameter in g++ 4.4.1 hannibal81
@ 2010-03-04 20:19 ` Andrew Pinski
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Pinski @ 2010-03-04 20:19 UTC (permalink / raw)
To: hannibal81; +Cc: gcc-bugs
On Thu, Mar 4, 2010 at 10:16 AM, hannibal81 <jallou07@yahoo.fr> wrote:
> template<typename P, template<typename T> class ST=std::vector>
std::vector has two template arguments not just one. One of them has
a default value though. But the C++ standard requires that the number
of template arguments to match inside a template argument, this code
is invalid. GCC before 4.3 accepted the code as an "undocumented
extension" (undocumented meaning it was a bug).
Thanks,
Andrew Pinski
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-03-04 20:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-04 18:16 problem with template parameter in g++ 4.4.1 hannibal81
2010-03-04 20:19 ` Andrew Pinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).