fla*_*nik 6 c++ unordered-map tr1 visual-c++
我正在使用MS VC 2008和一些项目英特尔C++编译器11.0.是否值得在生产中使用tr1功能?他们会保持新标准吗?
例如,现在我使用stdext::hash_map.TR1定义std::tr1::unordered_map.但在MS中,实现unordered_map只是他们的stdext::hash_map,以另一种方式模板化.
我的建议是使用包含您使用的TR1项的命名空间的别名.这样,当编译器支持TR1版本时,您将能够"移动"使用TR1版本.
namespace cpp0x = std::tr1;
cpp0x::unordered_map<std::string, int> mymap;
Run Code Online (Sandbox Code Playgroud)
对于C++ 0x编译器,第一行变为:
namespace cpp0x = std;
Run Code Online (Sandbox Code Playgroud)
你可以把剩下的一个人留下来.