vc++ 6.0使用boost::shared_ptr(boost版本boost_1_33_1)出现以下错误:
f:/c++/boost_1_33_1/boost/shared_ptr.hpp(321) : error C2039: 'type_info' : is not a member of 'std'
f:/c++/boost_1_33_1/boost/shared_ptr.hpp(342) : see reference to class template instantiation 'boost::shared_ptr<T>' being compiled
f:/c++/boost_1_33_1/boost/shared_ptr.hpp(321) : error C2039: 'type_info' : is not a member of 'std'
c:/program files/microsoft visual studio/vc98/include/utility(26) : see reference to class template instantiation 'boost::shared_ptr<class PersistentObject>' being compiled
c:/program files/microsoft visual studio/vc98/include/xtree(28) : see reference to class template instantiation 'std::pair<class Key const ,class boost::shared_ptr<class PersistentObject> >' being compiled
c:/program files/microsoft visual studio/vc98/include/map(46) : see reference to class template instantiation 'std::_Tree<class Key,struct std::pair<class Key const ,class boost::shared_ptr<class PersistentObject> >,struct std::map<class Key
,class boost::shared_ptr<class PersistentObject>,struct std::less<class Key>,class std::allocator<class boost::shared_ptr<class PersistentObject> > >::_Kfn,struct std::less<class Key>,class std::allocator<class boost::shared_ptr<class PersistentObje
ct> > >' being compiled
f:/vc6/tinyorm/orm/abstractmapper.h(96) : see reference to class template instantiation 'std::map<class Key,class boost::shared_ptr<class PersistentObject>,struct std::less<class Key>,class std::allocator<class boost::shared_ptr<class Persis
tentObject> > >' being compiled
PersistentCriteria.cpp
f:/c++/boost_1_33_1/boost/shared_ptr.hpp(321) : error C2039: 'type_info' : is not a member of 'std'
f:/c++/boost_1_33_1/boost/shared_ptr.hpp(342) : see reference to class template instantiation 'boost::shared_ptr<T>' being compiled
f:/c++/boost_1_33_1/boost/shared_ptr.hpp(321) : error C2039: 'type_info' : is not a member of 'std'
c:/program files/microsoft visual studio/vc98/include/utility(26) : see reference to class template instantiation 'boost::shared_ptr<class PersistentObject>' being compiled
c:/program files/microsoft visual studio/vc98/include/xtree(28) : see reference to class template instantiation 'std::pair<class Key const ,class boost::shared_ptr<class PersistentObject> >' being compiled
c:/program files/microsoft visual studio/vc98/include/map(46) : see reference to class template instantiation 'std::_Tree<class Key,struct std::pair<class Key const ,class boost::shared_ptr<class PersistentObject> >,struct std::map<class Key
,class boost::shared_ptr<class PersistentObject>,struct std::less<class Key>,class std::allocator<class boost::shared_ptr<class PersistentObject> > >::_Kfn,struct std::less<class Key>,class std::allocator<class boost::shared_ptr<class PersistentObje
ct> > >' being compiled
f:/vc6/tinyorm/orm/abstractmapper.h(96) : see reference to class template instantiation 'std::map<class Key,class boost::shared_ptr<class PersistentObject>,struct std::less<class Key>,class std::allocator<class boost::shared_ptr<class Persis
tentObject> > >' being compiled
PersistentObject.cpp
跟踪发现,原来错误的代码出现在(红色处):
void * _internal_get_deleter(std::type_info const & ti) const
{
return pn.get_deleter(ti);
}
将代码中的 std::一一 去掉后(搜索一下,有好几处),居然编译通过。
分析原因:
type_info 为运行时类型识别功能提供支持,vc++6.0 环境中自带了TYPEINFO.H头文件(在路径C:/Program Files/Microsoft Visual Studio/VC98/Include下),而该文件中定义的class type_info 并不在std 的namespace中。