mercredi 22 juillet 2015

candidate template ignored: substitution failure(error with clang but not g++)

I have a problem of substitution failure, and answers of some similar questions do not help me.

I have asked this question two days ago, but it was blocked somehow and I have no time to wait for it to reopen.

Here is the main part:

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)
    {
       // ...
    }
    // ...
};

And I call this template function like:

int main()
{
   // ... 
   const int DENOISE_UR[3][4] = {/*...*/};
   Partition<1,2> partition;
   partition.readPattern(DENOISE_UR);
   // ...
}

Using g++, it compiles.

When using clang++(linux) to compile(clang++ -std=c++11 xxx.cpp), it resulted in the following compiling error:

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)

Why?

Aucun commentaire:

Enregistrer un commentaire