何らかの理由で、この関数へのポインターを varadic 関数に渡そうとすると、次のエラーが発生します。
1>c:\... : error C2664: 'PyArg_ParseTuple' : cannot convert parameter 3 from 'int (__cdecl *)(PyObject *,void *)' to '...'
1> Context does not allow for disambiguation of overloaded function
PyArg_ParseTuple(args, "O&O&:CreateWindow",
&Arg_Size2U<1>, &size,
&Arg_String<2>, &title);
テンプレート関数にはオーバーロードがなく、テンプレートパラメーターは明示的に定義されているため、どの関数にポインターを渡すかについては疑問がありません...
引数変換関数ごとに多くのバージョンを作成する必要はありませんが、エラーが発生した場合に例外に引数番号を含めることができる方法はありますか? (引数番号をパラメーターとして渡す方法がさらに良いので、dllに関数の複数のコピーがありません。)
EDIT:これもコンパイルエラーになるようです。テンプレート関数への関数ポインタを作成する方法はありませんか、それとも通常の関数とは異なる方法で行う必要がありますか?
int (*sizeConv)(PyObject *,void *) = Arg_MakeSize2U<1>;
1>c:\... : error C2440: 'initializing' : cannot convert from 'int (__cdecl *)(PyObject *,void *)' to 'int (__cdecl *)(PyObject *,void *)'
1> None of the functions with this name in scope match the target type
関数は次のように宣言されます。
template<int ARG> int Arg_MakeSize2U(PyObject *obj, void *out)
EDIT2:オペレーターのアドレスを追加すると、さらに別の異なるエラーが発生しました...
int (*sizeConv)(PyObject *,void *) = &Arg_MakeSize2U<1>;
1>c:\... : error C2440: 'initializing' : cannot convert from 'overloaded-function' to 'int (__cdecl *)(PyObject *,void *)'
1> None of the functions with this name in scope match the target type