Why I'm getting the following error when I try to use an const int std::array? I had to replace "<" for "<\" in the error message to show it correctly:
#include <array>
#include <iostream>
using namespace std;
int main() {
array<const int, 4> vals;
return 0;
}
test.cpp: In function ‘int main()’:
test.cpp:7:22: error: use of deleted function ‘std::array::array()’
array<\const int, 4> vals; ^~~~
In file included from test.cpp:1:0: /usr/include/c++/7.3.0/array:94:12: note: ‘std::array<\const int, 4>::array()’ is implicitly deleted because the default definition would be ill-formed: struct array ^~~~~
/usr/include/c++/7.3.0/array:94:12: error: uninitialized const member in ‘struct std::array<\const int, 4>’
/usr/include/c++/7.3.0/array:110:56: note: ‘const int std::array<\const int, 4>::_M_elems [4]’ should be initialized typename _AT_Type::_Type _M_elems; ^~~~~~~~
Aucun commentaire:
Enregistrer un commentaire