vendredi 29 juillet 2016

Issues with map (2)

when I try to build below code with VS2010 it end in error

#include <windows.h>
#include <map>

using namespace std;


struct WayStruct{
    double ID;
    string Neighbours;
};
map <char, WayStruct> WayMap;
WayStruct WaysFind;


int main(int argc, char *argv[])
{     
                    WaysFind.ID=9999;
                    WaysFind.Neighbours="test";
                    WayMap.insert(make_pair("123",WaysFind));


}

VS2010 is returning below error(s)

c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\utility(163): error C2440: 'initializing' : cannot convert from 'const char *' to 'const char'
              There is no context in which this conversion is possible
              c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\utility(255) : see reference to function template instantiation 'std::_Pair_base<_Ty1,_Ty2>::_Pair_base<_Ty,WayStruct>(_Other1 &&,_Other2 &&)' being compiled
              with
              [
                  _Ty1=const char,
                  _Ty2=WayStruct,
                  _Ty=const char *,
                  _Other1=const char *,
                  _Other2=WayStruct
              ]
              c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xmemory(208) : see reference to function template instantiation 'std::pair<_Ty1,_Ty2>::pair<const char*,WayStruct>(std::pair<const char *,_Ty2> &&)' being compiled
              with
              [
                  _Ty1=const char,
                  _Ty2=WayStruct
              ]
              c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xmemory(280) : see reference to function template instantiation 'void std::allocator<_Ty>::construct<std::pair<_Ty1,_Ty2>>(std::pair<const
_Kty,_Ty2> ,_Other &&)' being compiled
              with
              [
                  _Ty=std::pair<const char,WayStruct>,
                  _Ty1=const char *,
                  _Ty2=WayStruct,
                  _Kty=char,
                  _Other=std::pair<const char *,WayStruct>
              ]
              c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xtree(592) : see reference to function template instantiation 'void std::_Cons_val<std::allocator<_Ty>,_Ty,std::pair<_Ty1,_Ty2>>(_Alloc &,std::pair<const _Kty,_Ty2> *,std::pair<_Ty1,_Ty2> &&)' being compiled
              with
              [
                  _Ty=std::pair<const char,WayStruct>,
                  _Ty1=const char *,
                  _Ty2=WayStruct,
                  _Alloc=std::allocator<std::pair<const char,WayStruct>>,
                  _Kty=char
              ]
              c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xtree(755) : see reference to function template instantiation 'std::_Tree_nod<_Traits>::_Node
*std::_Tree_val<_Traits>::_Buynode<_Ty>(_Valty &&)' being compiled
              with
              [
                  _Traits=std::_Tmap_traits<char,WayStruct,std::less<char>,std::allocator<std::pair<const char,WayStruct>>,false>,
                  _Ty=std::pair<const char *,WayStruct>,
                  _Valty=std::pair<const char *,WayStruct>
              ]
              Source.cpp(19) : see reference to function template instantiation 'std::pair<_Ty1,_Ty2> std::_Tree<_Traits>::insert<std::pair<const char *,WayStruct>>(_Valty &&)' being compiled
              with
              [
                  _Ty1=std::_Tree_iterator<std::_Tree_val<std::_Tmap_traits<char,WayStruct,std::less<char>,std::allocator<std::pair<const char,WayStruct>>,false>>>,
                  _Ty2=bool,
                  _Traits=std::_Tmap_traits<char,WayStruct,std::less<char>,std::allocator<std::pair<const char,WayStruct>>,false>,
                  _Valty=std::pair<const char *,WayStruct>
              ]
    c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\utility(163): error C2439: 'std::_Pair_base<_Ty1,_Ty2>::first' : member could not be initialized
              with
              [
                  _Ty1=const char,
                  _Ty2=WayStruct
              ]
              c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\utility(166) : see declaration of 'std::_Pair_base<_Ty1,_Ty2>::first'
              with
              [
                  _Ty1=const char,
                  _Ty2=WayStruct
              ]

    Build FAILED.

Aucun commentaire:

Enregistrer un commentaire