的非類型的函數模板已經在SO讀幾個答案(如here和here),我想通了,有兩種常用的替代品在模板庫調用函數模板:C++使用聲明模板基類
template<typename T>
struct Base
{
template<int N>
auto get() const
{
return N;
}
};
template<typename T>
struct Derived : public Base<T>
{
//first alternative
auto f0() const { return this-> template get<0>(); }
//second alternative
auto f1() const { return Base<T>::template get<1>(); }
};
但有也是一個相當於using Base<T>::foo
聲明非模板的功能呢?也許類似
template<int N>
using Base<T>::template get<N>; //does not compile in gcc
參見[CWG 109](http://wg21.link/cwg109) –
@ T.C。所以這不是標準的一部分,我的部分(!)答案只顯示了VS2015提供的擴展? –