Here is an example of the problem I am having:
#include <stdio.h>
#include <iostream>
template<std::size_t U, std::size_t V>
void func2(int (&twoDArrayA)[U][V], const int shift){
const int length = 1 << shift;
int twoDArrayB[length][length]; //Successful
}
//template<std::size_t A> <-- Tried to solve the problem by adding this
void func1(const int shift){
const int length = 1 << shift;
int twoDArrayA[length][length]; //Failed
func2(twoDArrayA,shift);
}
int main() {
const int shift = 3;
func1(shift);
}
Error message:
error: no matching function for call to 'func2(int [length][length], const int&)' template argument deduction/substitution failed: variable-sized array type 'int' is not a valid template argument
I thought it is because of the use of the template before the func2, so I tried to do the same thing on func1. The attempt of making the call to func1 fails instead. Error message:
error: no matching function for call to 'func1(const int&)' template argument deduction/substitution failed: couldn't deduce template parameter 'A'
Is there any way I can pass such an argument as twoDArrayA to func2?