I have a function, in which const std::map<std::string, Array2D<unsigned short>&>* pDataPool
is one of its input parameters. There a code snippet in the function body as follows:
std::map<std::string, Array1D<unsigned short>*> DataBuffers;
if (pDataPool != NULL)
{
for (std::map<std::string, Array2D<unsigned short>&>::iterator it = pDataPool->begin();
it != pDataPool->end(); it++) // Error
{
std::string sKeyName = it->first;
DataBuffers[sKeyName] = new Array1D<unsigned short>(2048);
}
}
Compiler output:
1>e:\program files\microsoft visual studio 9.0\vc\include\map(168) : error C2529: '[]' : reference to reference is illegal
1> f:\tips\tips\fy2svsdataiohandler.cpp(77) : see reference to class template instantiation 'std::map<_Kty,_Ty>' being compiled
1> with
1> [
1> _Kty=std::string,
1> _Ty=Array2D<unsigned short> &
1> ]
1>f:\tips\tips\fy2svsdataiohandler.cpp(77) : error C2440: 'initializing' : cannot convert from 'std::_Tree<_Traits>::const_iterator to <br/>'std::_Tree<_Traits>::iterator'
1> with
1> [
1> _Traits=std::_Tmap_traits<std::string,Array2D<unsigned short> &,std::less<std::string>,std::allocator<std::pair<const <br/> std::string,Array2D<unsigned short> &>>,false>
1> ]
1> No constructor could take the source type, or constructor overload resolution was ambiguous
1>Build log was saved at "file://f:\Tips\Tips\Debug\BuildLog.htm"
1>Tips - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========