2010-12-08 53 views
2

我有這樣的事情:的一種方式,縮短報關

template<class Key, 
       class Value, 
       class Compare_p = Compare<ByKey>, 
       template<class,class> class Insert_p = NoOverride, 
       template<class> class FailureSignal_p = ThrowOnFailure, 
       class AllocFactor_p = AllocFactorScientific<>, 
       class Alloc = Allocator<FailureSignal_p> 
       > 
     class Map : private Map_Base<Implementation> //Implementation is a Link with identical 
//params to Map 
     { 
     public: 
//I've tried to use typedef here but it's too late 
      typedef LinkImplementation<Pair<Key,Value>,Compare_p,Insert_p,FailureSignal_p,AllocFactor_p,Alloc> Implementation; 
    }; 

那麼大Q是:有沒有辦法作出這一聲明(LinkImplementation <的>)縮短?

回答

1

也許創建地圖參數,這樣的一個模板「結構」:

 
template <class Key, ... blablabla > 
struct MapParams{ 
typedef Key key_t; 
typedef Value value_t; 
.................. 
}; 

然後用這個「結構」作爲一個模板參數 兩個地圖和Map_Base模板?

+0

難道這不是說用戶受苦? `地圖 x` vs`地圖> x`? – UncleBens 2010-12-08 23:58:21