Please find my code snippet below:
std::vector<int> idx1;
std::vector<int> idx2;
framx[0].get_idx_of(atm1,idx1);
framx[0].get_idx_of(atm2,idx2);
std::vector<bool> iniz;
const int sz1=idx1.size();
const int sz2=idx2.size();
array<array<array<double,7>,sz2>,sz1> lnmat;
An please find the error during compiling with both C++ and clang++.
analysis.cpp:408:33: error: the value of ‘sz2’ is not usable in a constant expression
array<array<array<double,7>,sz2>,sz1> lnmat;
^~~
analysis.cpp:407:15: note: ‘sz2’ was not initialized with a constant expression
const int sz2=idx2.size();
^~~
analysis.cpp:408:36: error: the value of ‘sz2’ is not usable in a constant expression
array<array<array<double,7>,sz2>,sz1> lnmat;
^
analysis.cpp:407:15: note: ‘sz2’ was not initialized with a constant expression
const int sz2=idx2.size();
^~~
analysis.cpp:408:36: note: in template argument for type ‘long unsigned int’
array<array<array<double,7>,sz2>,sz1> lnmat;
^
analysis.cpp:408:38: error: the value of ‘sz1’ is not usable in a constant expression
array<array<array<double,7>,sz2>,sz1> lnmat;
^~~
analysis.cpp:406:15: note: ‘sz1’ was not initialized with a constant expression
const int sz1=idx1.size();
^~~
analysis.cpp:408:41: error: template argument 1 is invalid
array<array<array<double,7>,sz2>,sz1> lnmat;
^
analysis.cpp:408:41: error: the value of ‘sz1’ is not usable in a constant expression
analysis.cpp:406:15: note: ‘sz1’ was not initialized with a constant expression
const int sz1=idx1.size();
^~~
analysis.cpp:408:41: note: in template argument for type ‘long unsigned int’
array<array<array<double,7>,sz2>,sz1> lnmat;
Can you please let me know the reasong for this error in assignment of the variable lnmat? It seems that proably the array declaration is not identifying the constant or there is some problem with its declaration.
P.S.: Please do not refer me answer to this question.