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
c ++ c ++ 11 templates clang clang ++


source to share


No one has answered this question yet

Check out similar questions:

1643
Why templates can only be implemented in a header file?
961
Where and why do I need to put the keywords "pattern" and "name-type"?
366
Pretty printable STL STL containers
15
argument template failure / substitution when using std :: function and std :: bind
ten
Function template argument inference (class template vs funtion)
8
candidate pattern ignored: replacement failed (bug with clang but not g ++)
3
Template parameter bundle not working on Clang but not VS 2015
3
Substitution error for template template argument
1
Can the templates function return type depend on the same return type function template recursively?
0
clang: candidate pattern ignored: substitution error: typedef 'type' cannot be specified with a class specifier



All Articles
Loading...
X
Show
Funny
Dev
Pics