Ich habe ein Problem der Substitution fehlgeschlagen, und Antworten auf einige ähnliche Fragen helfen mir nicht. HierKandidat Vorlage ignoriert: Substitution Fehler (Fehler mit Clang aber nicht g ++)
ist der Code:
template<int dim, int loop>
class Reference{
public:
//...
template<int r, int c> using matrix_t = int[r][c];
Reference(const matrix_t<dim, loop> &mat){}
};
template<int dim, int loop>
class Partition{
// ...
public:
// ...
template<int r, int c> using matrix = int[r][c];
template<int r, int c> void readPattern(const matrix<r,c> &pattern)
{
// ...
}
// ...
};
Und ich nenne diese Template-Funktion wie folgt:
int main()
{
// ...
const int DENOISE_UR[3][4] = {/*...*/};
Partition<1,2> partition;
partition.readPattern(DENOISE_UR);
// ...
}
Mit g ++ kompiliert.
Wenn Klirren mit ++ (Linux) zu kompilieren (clang++ -std=c++11 xxx.cpp
), führte es in den folgenden Zusammenstellung Fehler:
error: no matching function for call to 'readPattern'
note: candidate template ignored: substitution failure[ with r = 3, c = 4 ]
template<int r, int c> void readPattern(const matrix<r,c> &pattern)
Warum?
oO wenn Sie die Definition von 'Reference' entfernen, [es kompiliert] (http: // melpon.org/wandbox/permlink/xx2K1gu0J4PFutiP) ... – Columbo
@Columbo Genau das ist das Problem. Ich brauche die Klasse 'Reference' in der Klasse' Partition' – Shindou
@Columbo Ändern Sie die erste Aliasvorlage in 'long [r] [c]': http://melpon.org/wandbox/permlink/0DHbcs3C0dm9H3gX ò.Ó – dyp