This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c++/7301: template template parameters are not correctly parsed when using 'typename'
- From: a9804814 at unet dot univie dot ac dot at
- To: gcc-gnats at gcc dot gnu dot org
- Date: 13 Jul 2002 14:01:35 -0000
- Subject: c++/7301: template template parameters are not correctly parsed when using 'typename'
- Reply-to: a9804814 at unet dot univie dot ac dot at
>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: