模板函數不支持template template parameter。例如:
1 template< template<class T> class Foo>
2 void bar( Foo<T> test )
3 {
4 //do something 

5 }
注意,這是編譯不通過的,編譯器會提示說參數T無效。但是有時候咱們必須依賴T,怎么辦呢?
其實只要引入一個輔助的參數就可以啦:
1 template< template<class> class Foo, class T>
2 void bar( Foo<T> test )
3 {
4 //do something 

5 }
posted on 2010-01-19 19:41
Leix 閱讀(197)
評論(0) 編輯 收藏 引用