Mam problem z brakiem wymiany, a odpowiedzi na niektóre podobne pytania nie pomagają mi.Szablon kandydata zignorowany: błąd zastąpienia (błąd z clang ale nie g ++)
Oto kod:
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)
{
// ...
}
// ...
};
I wywołać tę funkcję szablonu tak:
int main()
{
// ...
const int DENOISE_UR[3][4] = {/*...*/};
Partition<1,2> partition;
partition.readPattern(DENOISE_UR);
// ...
}
Korzystanie g ++, kompiluje.
Przy użyciu szczęk ++ (Linux) do kompilacji (clang++ -std=c++11 xxx.cpp
), wynikało to w następujący opracowującym błędu:
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)
Dlaczego?
oO jeśli usunąć definicję 'Reference' [kompiluje] (http: // melpon.org/wandbox/permlink/xx2K1gu0J4PFutiP) ... – Columbo
@ Columbo To jest właśnie problem. Muszę użyć klasy 'Reference' w klasie' Partition' – Shindou
@ Columbo Zmień pierwszy szablon aliasu na 'long [r] [c]': http://melpon.org/wandbox/permlink/0DHbcs3C0dm9H3gX ò.Ó – dyp