keine Instanz von funktionsvorlage entspricht der argument-Liste (drucken möchten, array)

Beim Versuch zu kompilieren dieser

template<typename type,const char* format>__device__ void d_prettyPrintVector(type* v, const unsigned int size)
{
    printf("\n ");
    for(int i=0; i<size; i++)
            printf(format, v[i]);
}
template<> void d_prettyPrintVector<float, "%4.1f ">(float*, const    unsigned int);
template<> void d_prettyPrintVector<int,   "%2d "  >(int*,   const unsigned int);
template<> void d_prettyPrintVector<char,  "%2d "  >(char*,  const unsigned int);
template<> void d_prettyPrintVector<bool,  "%d"    >(bool*,  const unsigned int);

und verwenden Sie es wie diese

d_prettyPrintVector(dc, blockDim.x);

Ich bin immer

kernels.cu(104): error: no instance of function template "d_prettyPrintVector" matches the argument list
        argument types are: (int *, const unsigned int)

was ist falsch?

update: wenn Sie nicht mit der Funktion (nur instanziieren der Schablone), bekomme ich folgenden Fehler: kernels.cu:65: error: a cast to a type other than an integral or enumeration type cannot appear in a constant-expression Kernel.cu:65: Fehler: template-id 'd_prettyPrintVector<int <expression-Fehler> >" für "nichtig d_prettyPrintVector(int*, unsigned int)" nicht mit jedem template-Deklaration`
mögliche Duplikate von Übergeben const char* als template-argument
Danke, es ist das gleiche zugrunde liegende problem, aber die workarounds sind unterschiedlich. Außerdem sah ich, dass eine Frage als ich fragte, mine, aber ich wusste nicht, wie es zusammenhängt. Ich Wette, dass es Neulinge wie mich, wer wird davon profitieren ein weiteres Beispiel.

InformationsquelleAutor Leo | 2015-03-12

Schreibe einen Kommentar