First I defined a template overloading function(c:\git\feim\core\qpropertylist.hpp)
template<class T>
inline const T QPropertyList::get(const std::string& key, const T& defVal) const
{
const_iterator it = find(key);
if (it!=this->end())
{
it->second.setKey(key); //To do : remove this
return it->second;
} else {
return defVal;
}
}
In the source file( c:\git\feim\core\capfloorleg.c(77) ), I begin to make this template instantiation
tenor2 = aPL.get("Tenor2", std::string(""));
Then I get the error as follows:
>c:\git\feim\core\qpropertylist.hpp(114): error C2668: 'std::basic_string<_Elem,_Traits,_Alloc>::basic_string' : ambiguous call to overloaded function
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ] (..\..\core\capFloorLeg.C)
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstring(896): could be 'std::basic_string<_Elem,_Traits,_Alloc>::basic_string(std::basic_string<_Elem,_Traits,_Alloc> &&) throw()'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstring(789): or 'std::basic_string<_Elem,_Traits,_Alloc>::basic_string(const _Elem *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1> while trying to match the argument list '(STC::QProperty)'
1> c:\git\feim\core\capfloorleg.c(77) : see reference to function template instantiation 'const T STC::QPropertyList::get<std::basic_string<_Elem,_Traits,_Alloc>>(const std::string &,const T &) const' being compiled
1> with
1> [
1> T=std::basic_string<char,std::char_traits<char>,std::allocator<char>>,
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
Error 2 error C2668: 'std::basic_string<_Elem,_Traits,_Alloc>::basic_string' : ambiguous call to overloaded function c:\git\feim\core\qpropertylist.hpp 111 1 core
I know this error is caused by the move constructor when I want to use implicit conversion (std::string(""))introduced by VS11.0, since in the VS8, everything is fine.
Anyone have a good idea how to avoid this error? Thanks a lot!!
Aucun commentaire:
Enregistrer un commentaire