GCC中使用hash_map_学着站在巨人的肩膀上_百度空间
GCC中使用hash_map
If you have tried to use some STL containers with GCC, such as hash_map:
// error: hash_map: No such file or directory
#include <hash_map>
int main()
{
// error: ‘hash_map’ is not a member of ‘std’
std::hash_map<int,int> hm;
return 0;
}
Then you have realized that the code above does not compile. That's because on GCC, hash_map is not regarded as a standard container, but rather as a extension included in the __gnu_cxx namespace. In order to use hash_map and other extended containers with a minimum impact in your code (which is very important if it's intended to be cross-platform), you can use the following solution:
#ifdef __GNUC__
#include <ext/hash_map>
#else
#include <hash_map>
#endif
namespace std
{
using namespace __gnu_cxx;
}
int main()
{
std::hash_map<int,int> hm;
return 0;
}
Hope that helps.
原文链接: https://www.cnblogs.com/lexus/archive/2012/11/15/2771342.html
欢迎关注
微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍
原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/69532
非原创文章文中已经注明原地址,如有侵权,联系删除
关注公众号【高性能架构探索】,第一时间获取最新文章
转载文章受原作者版权保护。转载请注明原作者出处!