[問題] class template內的class template ...

看板C_and_CPP作者 (hpps)時間12年前 (2013/05/09 17:32), 編輯推噓0(002)
留言2則, 1人參與, 最新討論串1/1
template<class T> class A { public: template<class U> struct inner { typedef A<U> other; }; T val; }; template<class T, class U> class B { public: /* ??? */ typedef typename U::template inner<T>::other value_type; }; int main() { cout << sizeof( A<int>::inner<char>::other ) << endl; cout << sizeof( B< double, A<int> >::value_type ) << endl; return 0; } /* ??? */ 下面那一行, 有人看過這種寫法嗎? 是什麼意思呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.116.164.87

05/09 17:38, , 1F
就是一個 typedef 而已啊..只是有 template 需要 typename
05/09 17:38, 1F

05/09 17:39, , 2F
來表示他是個 type 不是 variable
05/09 17:39, 2F
文章代碼(AID): #1HYsqWbx (C_and_CPP)