c++ unordered_map compiling issue with g++
来源:互联网 发布:groovy mac 编辑:程序博客网 时间:2024/05/29 10:48
Question:
I am using g++ in Ubuntu
g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3I have this code
#include<unordered_map>using namespace std;bool ifunique(char *s){ unordered_map<char,bool> h; if(s== NULL){ return true; } while(*s){ if(h.find(*s) != h.end()){ return false; } h.insert(*s,true); s++; } return false;}when I compile using
g++ mycode.cc
I got errorerror: 'unordered_map' was not declared in this scope
Answer:
In GCC 4.4.x, you should only have to #include <unordered_map>
, and compile with this line:
g++ -std=c++0x source.cxx
More information about C++0x support in GCC.
edit regarding your problem
You have to do std::make_pair<char, bool>(*s, true)
when inserting.
Also, your code would only insert a single character (the dereferencing via *s
). Do you intend to use a single char
for a key, or did you mean to store strings?
0 0
- c++ unordered_map compiling issue with g++
- c++: unordered_map
- Compiling and Linking MKL with Microsoft* Visual C/C++*
- Compiling C
- Compiling C
- Compiling C
- Compiling C
- Compiling FlightGear 1.0.0 with Visual C++.net 2005
- Compiling Java with GCJ
- Compiling Java with makefile
- Live555: Compiling with VS2008
- Compiling OpenSSL with MinGW
- asterisk compiling with mp3
- Fixed compiling bug ('unordered_map' file not found) under Apple.
- C++unordered_map使用例子
- 【c++】unordered_set和unordered_map
- Compiling newest Boost_1_53_0 with VS2008
- Compiling VIM with python support
- 使用VS2010开发ActiveX(MFC)控件(转载)
- 九个PHP中很有用的功能
- TCP状态转换图_legend050709
- 编程内存分布
- C# WinForm获取 当前执行程序路径的几种方法
- c++ unordered_map compiling issue with g++
- asp.net笔记
- 基础知识
- 我是如何自学编程的——“3遍读书法”
- 利用HTML5的一个重要特性 —— DeviceOrientation来实现手机网站上的摇一摇功能
- mini2440内核停在booting the kernel问题以及无法运行linuxrc问题的解决方法
- ViewFs Guide
- C#安装部署打包SQLSERVER数据库
- jQuery点击li标签打开新链接