Bug 54665 - [C++11] template alias to template does not work
Summary: [C++11] template alias to template does not work
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-21 22:09 UTC by Matthew Woehlke
Modified: 2012-09-21 23:46 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Woehlke 2012-09-21 22:09:16 UTC
Template aliases, as described in N2258[1], are not fully implemented. Specifically, they do not work if the type being aliased is itself a template.

Simple test case (taken from Wikipedia[2]):

template <typename First, typename Second, int Third>
class SomeType;
class OtherType;

template <typename Second>
using TypedefName = typename SomeType<OtherType, Second, 5>;

int main()
{
  return 0;
}


This fails to compile with the error:

$ gcc -std=c++11 template-alias.cpp
template-alias.cpp:6:30: error: expected nested-name-specifier



[1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2258.pdf
[2] http://en.wikipedia.org/wiki/C++11#Alias_templates
Comment 1 Paolo Carlini 2012-09-21 23:46:39 UTC
The correct syntax is:

template <typename Second>
using TypedefName = SomeType<OtherType, Second, 5>;

ie, no "typename". You can find a good set of examples in the testsuite as: testsuite/g++.dg/cpp0x/alias-decl-*