This question already has an answer here:
- Why can't I make a vector of references? 8 answers
I have the following code
#include <vector>
using namespace std;
struct Test
{
Test();
vector<vector<long>> foo, bar;
vector<const vector<vector<long>>&> vect_table;
vector<const vector<vector<long>>&> construct_vect_table() const;
};
Test::Test()
{
vect_table = construct_vect_table();
}
Test::construct_vect_table() const
{
vector<const vector<vector<long>>&> vt(2);
vt.at(0) = foo;
vt.at(b) = bar;
}
int main()
{
vector<vector<long>> foo, bar;
}
It does not compile and am not sure why...
/usr/include/c++/7.2.0/bits/stl_vector.h:93:68: error: using invalid field
‘std::_Vector_base<_Tp, _Alloc>::_Vector_impl::_M_end_of_storage’
I am trying to build a vector of const reference to other vectors.
What am I doing wrong here?
Side note: using c++1z
.
Aucun commentaire:
Enregistrer un commentaire