public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/7301: template template parameters are not correctly parsed when using 'typename'
@ 2002-07-13  7:06 a9804814
  0 siblings, 0 replies; 4+ messages in thread
From: a9804814 @ 2002-07-13  7:06 UTC (permalink / raw)
  To: gcc-gnats


>Number:         7301
>Category:       c++
>Synopsis:       template template parameters are not correctly parsed when using 'typename'
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Sat Jul 13 07:06:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     a9804814@unet.univie.ac.at
>Release:        gnu 2.95.3-6(mingw special)
>Organization:
>Environment:

>Description:
The following programs use each 2 template template parameters, using the keyword 'typename'. The first template template parameter is used in a member function, the second in the classes template-list.

The only difference in code is that the first program does use the keyword 'typename', whereas the second uses 'class'.
According to the standard, these can be used interchangeably in template - parameter-lists.
However, the first program does not compile, the second does compile fine.
 

#include <vector>

template <typename T>
class Factory
{
 	public:

   	template <template <typename> typename U>
   	U<T> * Create() { return new U<T>; }
};       

template <typename T, template <typename> typename Container>
class ContainerClass
{
	private:
   	Container<T> Container_;
};


int main(int argc, char* argv[])
{                
 	Factory<int> iFactory;
   std::vector<int> *iVec = iFactory.Create<std::vector>();

   delete iVec;           

   ContainerClass<double, std::vector> dContainer;

   return 0;
}      


------------




#include <vector>

template <typename T>
class Factory
{
 	public:

   	template <template <typename> class U>
   	U<T> * Create() { return new U<T>; }
};

template <typename T, template <typename> class Container>
class ContainerClass
{
	private:
   	Container<T> Container_;
};


int main(int argc, char* argv[])
{                
 	Factory<int> iFactory;
   std::vector<int> *iVec = iFactory.Create<std::vector>();
   delete iVec;

   ContainerClass<double, std::vector> dContainer;

   return 0;
}      
>How-To-Repeat:

>Fix:
probalby a semantic parse error
>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: c++/7301: template template parameters are not correctly parsed when  using 'typename'
@ 2002-07-18  6:16 Kriang Lerdsuwanakij
  0 siblings, 0 replies; 4+ messages in thread
From: Kriang Lerdsuwanakij @ 2002-07-18  6:16 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/7301; it has been noted by GNATS.

From: Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
To: Thomas Mang <a9804814@unet.univie.ac.at>, lerdsuwa@gcc.gnu.org,
        a9804814@unet.univie.ac.at, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org,
        nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: c++/7301: template template parameters are not correctly
  parsed when  using 'typename'
Date: Thu, 18 Jul 2002 20:12:21 +0700

 Check out the language grammar, either from the standard or
 say The C++ Programming 3rd Ed or special Ed.  Only 'class'
 is allowed in the grammar.  The idea is with template type parameter,
 you can substitute it with any type such as 'int', etc.   So using 'class'
 there seems like it's restricted to class types, not any type like 
 'typename'.
 But with template template parameter, you can only substitute it with a
 template class.
 
 --Kriang
 
 At 11:15 17/7/02 +0200, Thomas Mang wrote:
 >Lots of greetings,
 >
 >Well, but isn't a template template parameter a special case of a template 
 >parameter(one, where the templated type is itself a template)?
 >
 >To use a metaphor, I think a 'template parameter' could be a base class, 
 >and a 'template template parameter' would be a derived class.
 >After all, template template parameters rely on template parameters (to 
 >instantiate the template template parameter).
 >
 >And as 'typename' and 'class' can be used interchangeable with template 
 >parameters, my (doubtless) point - of - view is they should be also able 
 >to be used interchangeably with template template parameters.
 >
 >
 >best regards
 >
 >Thomas
 >
 >
 >
 >
 >lerdsuwa@gcc.gnu.org schrieb:
 >>Synopsis: template template parameters are not correctly parsed when 
 >>using 'typename'
 >>
 >>State-Changed-From-To: open->closed
 >>State-Changed-By: lerdsuwa
 >>State-Changed-When: Sun Jul 14 08:20:06 2002
 >>State-Changed-Why:
 >>     Not a bug.  'typename' and 'class' can be interchanged only
 >>     for template type parameters, not template template parameters.
 >>
 >><http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7301>http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7301
 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: c++/7301: template template parameters are not correctly parsed when  using 'typename'
@ 2002-07-17  2:26 Thomas Mang
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Mang @ 2002-07-17  2:26 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/7301; it has been noted by GNATS.

From: Thomas Mang <a9804814@unet.univie.ac.at>
To: lerdsuwa@gcc.gnu.org, a9804814@unet.univie.ac.at, gcc-bugs@gcc.gnu.org,
   gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: c++/7301: template template parameters are not correctly parsed when 
 using 'typename'
Date: Wed, 17 Jul 2002 11:15:24 +0200

 --------------92BE452FA871B01A031BEB6F
 Content-Type: text/plain; charset=us-ascii
 Content-Transfer-Encoding: 7bit
 
 Lots of greetings,
 
 Well, but isn't a template template parameter a special case of a template parameter(one,
 where the templated type is itself a template)?
 
 To use a metaphor, I think a 'template parameter' could be a base class, and a 'template
 template parameter' would be a derived class.
 After all, template template parameters rely on template parameters (to instantiate the
 template template parameter).
 
 And as 'typename' and 'class' can be used interchangeable with template parameters, my
 (doubtless) point - of - view is they should be also able to be used interchangeably with
 template template parameters.
 
 
 best regards
 
 Thomas
 
 
 
 
 lerdsuwa@gcc.gnu.org schrieb:
 
 > Synopsis: template template parameters are not correctly parsed when using 'typename'
 >
 > State-Changed-From-To: open->closed
 > State-Changed-By: lerdsuwa
 > State-Changed-When: Sun Jul 14 08:20:06 2002
 > State-Changed-Why:
 >     Not a bug.  'typename' and 'class' can be interchanged only
 >     for template type parameters, not template template parameters.
 >
 > http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7301
 
 --------------92BE452FA871B01A031BEB6F
 Content-Type: text/html; charset=us-ascii
 Content-Transfer-Encoding: 7bit
 
 <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
 <html>
 Lots of greetings,
 <p>Well, but isn't a template template parameter a special case of a template
 parameter(one, where the templated type is itself a template)?
 <p>To use a metaphor, I think a 'template parameter' could be a base class,
 and a 'template template parameter' would be a derived class.
 <br>After all, template template parameters rely on template parameters
 (to instantiate the template template parameter).
 <p>And as 'typename' and 'class' can be used interchangeable with template
 parameters, my (doubtless) point - of - view is they should be also able
 to be used interchangeably with template template parameters.
 <br>&nbsp;
 <p>best regards
 <p>Thomas
 <br>&nbsp;
 <br>&nbsp;
 <br>&nbsp;
 <p>lerdsuwa@gcc.gnu.org schrieb:
 <blockquote TYPE=CITE>Synopsis: template template parameters are not correctly
 parsed when using 'typename'
 <p>State-Changed-From-To: open->closed
 <br>State-Changed-By: lerdsuwa
 <br>State-Changed-When: Sun Jul 14 08:20:06 2002
 <br>State-Changed-Why:
 <br>&nbsp;&nbsp;&nbsp; Not a bug.&nbsp; 'typename' and 'class' can be interchanged
 only
 <br>&nbsp;&nbsp;&nbsp; for template type parameters, not template template
 parameters.
 <p><a href="http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7301">http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&amp;database=gcc&amp;pr=7301</a></blockquote>
 </html>
 
 --------------92BE452FA871B01A031BEB6F--
 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: c++/7301: template template parameters are not correctly parsed when using 'typename'
@ 2002-07-14  8:20 lerdsuwa
  0 siblings, 0 replies; 4+ messages in thread
From: lerdsuwa @ 2002-07-14  8:20 UTC (permalink / raw)
  To: a9804814, gcc-bugs, gcc-prs, nobody

Synopsis: template template parameters are not correctly parsed when using 'typename'

State-Changed-From-To: open->closed
State-Changed-By: lerdsuwa
State-Changed-When: Sun Jul 14 08:20:06 2002
State-Changed-Why:
    Not a bug.  'typename' and 'class' can be interchanged only
    for template type parameters, not template template parameters.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7301


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-07-18 13:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-13  7:06 c++/7301: template template parameters are not correctly parsed when using 'typename' a9804814
2002-07-14  8:20 lerdsuwa
2002-07-17  2:26 Thomas Mang
2002-07-18  6:16 Kriang Lerdsuwanakij

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).