This is the mail archive of the gcc-prs@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]

c++/7301: template template parameters are not correctly parsed when using 'typename'


>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:


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