In my .h file I define the following container:
std::vector< std::map< std::string, const std::unique_ptr < std::vector<double> > > > loaded_data;
When I try to allocate memory or resize it in the .cpp file, using :
loaded_data.reserve(100);
or:
loaded_data.resize(100);
I get the following error:
/usr/include/c++/7.4.0/ext/new_allocator.h(136): error: function "std::pair<_T1, _T2>::pair(const std::pair<_T1, _T2> &) [with _T1=const std::__cxx11::string, _T2=const std::unique_ptr>, std::default_delete>>>]" (declared at line 303 of "/usr/include /c++/7.4.0/bits/stl_pair.h") cannot be referenced -- it is a deleted function
I do not understand why the constructor for such a pair would be deleted.
When I dot the same with similar objects, such as:
std::map < Variables,std::map<size_t, const std::unique_ptr < std::vector < std::vector<double> > > > >
I don't have any problem with reserve
. Note that this issue does not arise with older C++ container libraries.
Does anyone know why I have this error and which workaround could work?
Thanks
Aucun commentaire:
Enregistrer un commentaire