为什么Visual Studio 2010会在Boost 1.42.0中抛出此错误?

时间:2010-04-22 14:27:47

标签: c++ visual-studio-2010 boost

我正在尝试重新编译应用程序,在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>          ]

2 个答案:

答案 0 :(得分:8)

问题在于visual studio 2010,或者我应该说使用添加到visual studio 2010 tr1的其他模板,因此,std :: make_pair并不总是有效。改为配对&lt;&gt;所有错误都神奇地消失了。

因此,如果VC2010中存在模板问题并使用std:make_pair,请将其更改为配对&lt;&gt;并指定模板参数。

答案 1 :(得分:-5)

听起来Visual Studio可能正在做一些你不知道的事情。我认为您可以将Microsoft编译器与code::blocks IDE一起使用。您可以尝试每个编译器(VS 2005/2008/2010)。另外,尝试从源代码库中获取diff,以确保Microsoft没有“美化”您的代码。

注意:在找出问题后,您不必使用Code :: Blocks。它可能是解决这一特定问题的好工具。