1 template< template<class T> class Foo>
2 void bar( Foo<T> test )
3 {
4 //do something

5 }
注意,這是編譯不通過的,編譯器會提示說參數(shù)T無效。但是有時候咱們必須依賴T,怎么辦呢?2 void bar( Foo<T> test )
3 {
4 //do something


5 }
其實只要引入一個輔助的參數(shù)就可以啦:
1 template< template<class> class Foo, class T>
2 void bar( Foo<T> test )
3 {
4 //do something

5 }
2 void bar( Foo<T> test )
3 {
4 //do something


5 }