Faisal
2009-11-19 13:27:17 UTC
I've a map which uses GUID as the key.
#include <map>
#include <string>
#include <unknwn.h>
void main()
{
std::map<GUID, std::string> map;
GUID d1;
std::string szName = "test";
map[d1] = szName;
}
But when compiling this code in VS2008 shows following errors
c:\program files\microsoft visual studio 9.0\vc\include\functional
(143) : error C2784: 'bool std::operator <(const
std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem *)' : could not
deduce template argument for 'const
std::basic_string<_Elem,_Traits,_Alloc> &' from 'const GUID'
1> c:\program files\microsoft visual studio 9.0\vc\include
\string(150) : see declaration of 'std::operator <'
1> c:\program files\microsoft visual studio 9.0\vc\include
\functional(142) : while compiling class template member function
'bool std::less<_Ty>::operator ()(const _Ty &,const _Ty &) const'
1>c:\program files\microsoft visual studio 9.0\vc\include\functional
(143) : error C2784: 'bool std::operator <(const _Elem *,const
std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce
template argument for 'const _Elem *' from 'const GUID'
1> c:\program files\microsoft visual studio 9.0\vc\include
\string(140) : see declaration of 'std::operator <'
1>c:\program files\microsoft visual studio 9.0\vc\include\functional
(143) : error C2784: 'bool std::operator <(const
std::basic_string<_Elem,_Traits,_Alloc> &,const
std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce
template argument for 'const std::basic_string<_Elem,_Traits,_Alloc>
&' from 'const GUID'
1> c:\program files\microsoft visual studio 9.0\vc\include
\string(130) : see declaration of 'std::operator <'
1>c:\program files\microsoft visual studio 9.0\vc\include\functional
(143) : error C2784: 'bool std::operator <(const std::_Tree<_Traits>
&,const std::_Tree<_Traits> &)' : could not deduce template argument
for 'const std::_Tree<_Traits> &' from 'const GUID'
1> c:\program files\microsoft visual studio 9.0\vc\include\xtree
(1466) : see declaration of 'std::operator <'
1>c:\program files\microsoft visual studio 9.0\vc\include\functional
(143) : error C2784: 'bool std::operator <(const
std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2>
&)' : could not deduce template argument for 'const
std::reverse_iterator<_RanIt> &' from 'const GUID'
1> c:\program files\microsoft visual studio 9.0\vc\include
\xutility(2262) : see declaration of 'std::operator <'
1>c:\program files\microsoft visual studio 9.0\vc\include\functional
(143) : error C2784: 'bool std::operator <(const
std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2>
&)' : could not deduce template argument for 'const
std::_Revranit<_RanIt,_Base> &' from 'const GUID'
1> c:\program files\microsoft visual studio 9.0\vc\include
\xutility(2072) : see declaration of 'std::operator <'
1>c:\program files\microsoft visual studio 9.0\vc\include\functional
(143) : error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2>
&,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument
for 'const std::pair<_Ty1,_Ty2> &' from 'const GUID'
1> c:\program files\microsoft visual studio 9.0\vc\include
\utility(99) : see declaration of 'std::operator <'
1>c:\program files\microsoft visual studio 9.0\vc\include\functional
(143) : error C2676: binary '<' : 'const GUID' does not define this
operator or a conversion to a type acceptable to the predefined
operator
1
How can i solve this?
#include <map>
#include <string>
#include <unknwn.h>
void main()
{
std::map<GUID, std::string> map;
GUID d1;
std::string szName = "test";
map[d1] = szName;
}
But when compiling this code in VS2008 shows following errors
c:\program files\microsoft visual studio 9.0\vc\include\functional
(143) : error C2784: 'bool std::operator <(const
std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem *)' : could not
deduce template argument for 'const
std::basic_string<_Elem,_Traits,_Alloc> &' from 'const GUID'
1> c:\program files\microsoft visual studio 9.0\vc\include
\string(150) : see declaration of 'std::operator <'
1> c:\program files\microsoft visual studio 9.0\vc\include
\functional(142) : while compiling class template member function
'bool std::less<_Ty>::operator ()(const _Ty &,const _Ty &) const'
1>c:\program files\microsoft visual studio 9.0\vc\include\functional
(143) : error C2784: 'bool std::operator <(const _Elem *,const
std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce
template argument for 'const _Elem *' from 'const GUID'
1> c:\program files\microsoft visual studio 9.0\vc\include
\string(140) : see declaration of 'std::operator <'
1>c:\program files\microsoft visual studio 9.0\vc\include\functional
(143) : error C2784: 'bool std::operator <(const
std::basic_string<_Elem,_Traits,_Alloc> &,const
std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce
template argument for 'const std::basic_string<_Elem,_Traits,_Alloc>
&' from 'const GUID'
1> c:\program files\microsoft visual studio 9.0\vc\include
\string(130) : see declaration of 'std::operator <'
1>c:\program files\microsoft visual studio 9.0\vc\include\functional
(143) : error C2784: 'bool std::operator <(const std::_Tree<_Traits>
&,const std::_Tree<_Traits> &)' : could not deduce template argument
for 'const std::_Tree<_Traits> &' from 'const GUID'
1> c:\program files\microsoft visual studio 9.0\vc\include\xtree
(1466) : see declaration of 'std::operator <'
1>c:\program files\microsoft visual studio 9.0\vc\include\functional
(143) : error C2784: 'bool std::operator <(const
std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2>
&)' : could not deduce template argument for 'const
std::reverse_iterator<_RanIt> &' from 'const GUID'
1> c:\program files\microsoft visual studio 9.0\vc\include
\xutility(2262) : see declaration of 'std::operator <'
1>c:\program files\microsoft visual studio 9.0\vc\include\functional
(143) : error C2784: 'bool std::operator <(const
std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2>
&)' : could not deduce template argument for 'const
std::_Revranit<_RanIt,_Base> &' from 'const GUID'
1> c:\program files\microsoft visual studio 9.0\vc\include
\xutility(2072) : see declaration of 'std::operator <'
1>c:\program files\microsoft visual studio 9.0\vc\include\functional
(143) : error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2>
&,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument
for 'const std::pair<_Ty1,_Ty2> &' from 'const GUID'
1> c:\program files\microsoft visual studio 9.0\vc\include
\utility(99) : see declaration of 'std::operator <'
1>c:\program files\microsoft visual studio 9.0\vc\include\functional
(143) : error C2676: binary '<' : 'const GUID' does not define this
operator or a conversion to a type acceptable to the predefined
operator
1
How can i solve this?