動作しない、次のように私は、テンプレートテンプレートパラメータを使用:C++ 11の転送テンプレートテンプレートパラメータが
/* [1]: Definition containing a template template parameter */
template <typename T, template<class> class Kernel>
void ForEach(Kernel<T> kernel, T * pSrc, int elementCount) {
//....
}
/* [2]: Definition of a helper struct */
template <typename T> struct KernelStd {
//...
};
/* [3]: Use the previous definitions */
float arr1[5] = {1,2,3,4,5};
//The following two calls to ForEach do successfully compile
ForEach(KernelStd<float>(), arr1, 5); //USE1
ForEach<float>(KernelStd<float>(), arr1, 5); //USE2
/* [4]: Definition of a helper function */
template <typename F, typename ...Args>
void forwarder(F func1, Args && ...args) {
//...
func1(std::forward<Args>(args)...);
}
//But the following callS do not compile.
forwarder(ForEach, KernelStd<float>(), arr1, 5); //USE3
forwarder(ForEach<float>, KernelStd<float>(), arr1, 5); //USE4
私はVS2013更新5を使用していますが、私は次のエラーを取得する:
error C2783: 'void ForEach(Kernel<T>,T *,int)' : could not deduce
template argument for 'Kernel'
どれでも助けていただければ幸いです。
「ForEach」とはそれは何らかの形で「変換する」ことに関連していますか? 'KernelStd'とは何ですか? 'Kernel1'と何らかの関係がありますか?あなたが[MCVE](https://stackoverflow.com/help/mcve)を表示するのが最善でしょう –
私のコード断片の間違いを指摘してくれてありがとう。私はそれらを修正しました。 – fonishormon