テンプレート定義の外部でのtypename、templateの使用
http://d.hatena.ne.jp/faith_and_brave/20080128/1201510970のコメント欄に
テンプレート定義の外部では、限定子としてのtemplateは使えないと書いたのだが、
C++0xでは書いてもいいのね。
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#382
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#468
template <class T> struct foo { template <typename U> struct bar { }; }; template <class T> struct hoge { void func() { foo<int>::bar<int> a; // OK typename foo<int>::template bar<int> b; // 必要ないけど、OK foo<T>::bar<T> c; // NG typename foo<T>::template bar<T> d; // OK } }; int main() { foo<int>::bar<int> a; // OK typename foo<int>::template bar<int> b; // C++0xではこれもOK hoge<int> x; x.func(); return 0; }