3
我有這樣的模板類:如何使用模板別名刪除一個不必要的參數
template<typename T, T F(const std::string&)>
struct Builder
{
T operator()(const std::string& s) const { return F(s); }
typedef T type;
};
,因爲我需要一個類持有的函數,該函數返回(因爲我需要它的引用)的值。
正如你所看到的,我有兩個模板參數,但實際上第一個是多餘的。有可能以某種方式刪除它嗎?模板別名?東西比宏
這是一個很常見的問題,例如請參閱http://stackoverflow.com/q/10224392/981959 – 2015-03-13 11:35:52