gpt4 book ai didi

c++ - 为什么 Visual Studio 2010 会在 Boost 1.42.0 中抛出这个错误?

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:06:06 24 4
gpt4 key购买 nike

我正在尝试重新编译应用程序,它在 visual studio 2005 和 visual studio 2008 中编译正常,警告级别为 4。由于错误(见下文)来自 std:tr1,我认为存在一些冲突,但不确定如何解决。我的第一个想法是删除所有对 boost 的引用,例如,但随后我得到一个错误,它无法找到格式方法。所以这是错误之一:(不确定它是什么意思)任何想法,建议,解决方案?谢谢!

编辑:一开始我看到一条消息:编译器版本未知 - 请运行配置测试并报告结果

EDIT2:我认为导致此错误的一段代码:(已更改以保护无辜者)EDIT3:我更新了错误消息,即添加了更多..但是我收到了更多错误消息,例如这个..所以有一个更大的问题/问题。

 !m_someMap.insert( std::make_pair( "somestring", SomeClass::isTrue ) ).second
....
.....
inline bool isTrue ( const IDog & dog ) { return s.IsDogTrue(); }



1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\type_traits(197): error C2752: 'std::tr1::_Remove_reference<_Ty>' : more than one partial specialization matches the template argument list
1> with
1> [
1> _Ty=bool (__cdecl &)(const IDog &)
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\xtr1common(356): could be 'std::tr1::_Remove_reference<_Ty&&>'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\xtr1common(350): or 'std::tr1::_Remove_reference<_Ty&>'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\type_traits(962) : see reference to class template instantiation 'std::tr1::remove_reference<_Ty>' being compiled
1> with
1> [
1> _Ty=bool (__cdecl &)(const IDog &)
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(26) : see reference to class template instantiation 'std::tr1::decay<_Ty>' being compiled
1> with
1> [
1> _Ty=bool (__cdecl &)(const IDog &)
1> ]
1> C:\(PATH)\...(915) : see reference to class template instantiation 'std::tr1::_Unrefwrap<_Type>' being compiled
1> with
1> [
1> _Type=bool (__cdecl &)(const IDog &)
1> ]
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\type_traits(965): error C2528: 'abstract declarator' : pointer to reference is illegal
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\type_traits(349): error C2528: 'type' : pointer to reference is illegal
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\type_traits(967) : see reference to class template instantiation 'std::tr1::add_pointer<_Ty>' being compiled
1> with
1> [
1> _Ty=bool (__cdecl &)(const IDog &)
1> ]
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\type_traits(197): error C2752: 'std::tr1::_Remove_reference<_Ty>' : more than one partial specialization matches the template argument list
1> with
1> [
1> _Ty=bool (__cdecl &)(const char *,int,const char *,std::string &)
1> ]

最佳答案

问题出在 visual studio 2010 上,或者我应该说是在 visual studio 2010 tr1 中添加了额外的模板,因此,std::make_pair 并不总是有效。更改为 pair<>,所有错误都神奇地消失了。

所以,如果你在VC2010和使用std:make_pair时遇到模板问题,将其改为pair<>并指定模板参数。

关于c++ - 为什么 Visual Studio 2010 会在 Boost 1.42.0 中抛出这个错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2691680/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com