The compiler complains at the following code snippet, it says that cx isn't a constant expression. And since cx isn't constant, it is invalid to pass it in as a template argument of the function T(). However, isn't getFoo() a const function? Thus isn't x const and hence cx const? And even if x is not, isn't cx forced to be const with the const identifier?
What should I do to make cx const and be successfully passed as a valid template argument of T()?
//M is an instance of class C
unsigned int x = M.getFoo(); //isn't this supposedly be constant?
const unsigned int cx = x;
C<cx> Mt = M.T<cx>();
Calling the following 2 public member function of class C:
const int getFoo() const{
return foo; //a private variable which value is set in the constructor
}
<template unsigned int ROWS>
const C<ROWS> T() const{
//after some declarations and computations...
return Ct;
}