Candidate pattern ignored: replacement failed

I have a problem with swap replacement and answers to some similar questions don't help me.

Here's 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 this:

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

      

When using clang ++ (linux) to compile, it resulted in the following compilation 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?

What's strange is that the above codes were compiling and working on Visual Studio 2013.

// ================================================ ============================================ ====== =============

I am very sorry that this is my mistake in editing the question. I found that it compiles when you take this part alone. But in my project, it only gives the above compile error information.

So there must be some problems in my project.

// ================================================ ============================================ ====== =============

After some trying, I fixed the above issue by adding the main part of the class design Reference<int dim, int loop>

Can anyone help me with this problem?

+3


source to share





All Articles