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

5 }
注意,這是編譯不通過(guò)的,編譯器會(huì)提示說(shuō)參數(shù)T無(wú)效。但是有時(shí)候咱們必須依賴(lài)T,怎么辦呢?
其實(shí)只要引入一個(gè)輔助的參數(shù)就可以啦:
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 閱讀(211)
評(píng)論(0) 編輯 收藏 引用