错误:命名空间'std'中没有名为'stod'的成员

lak*_*esh 1 c++ sublimetext2

我在Sublime Text 2中运行代码.它向我显示错误:

item->open = std::stod(temp);
Run Code Online (Sandbox Code Playgroud)

错误是:

error: no member named 'stod' in namespace 'std'
                item->open = std::stod(temp);
Run Code Online (Sandbox Code Playgroud)

意识到sublime text 2无法运行c ++ 11代码,所以看了这篇文章:http://www.thefourtheye.in/2013/07/Compiling-Cpp-11-Programs-with-Sublime-Text-3. HTML

在C++中发布此代码.sublime.build:

{
 "cmd": ["g++", "-std=c++0x", "${file}", "-o", "${file_path}/${file_base_name}"],
 "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
 "working_dir": "${file_path}",
 "selector": "source.c, source.c++",
 "variants":
 [
   {
     "name": "Run",
     "cmd":["bash", "-c", "g++ -std=c++0x '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
   }
 ]
}
Run Code Online (Sandbox Code Playgroud)

但错误仍然存​​在.不知道为什么.需要一些指导......

UPDATE1:

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin12.4.0
Thread model: posix
Run Code Online (Sandbox Code Playgroud)

Update2:更改为c ++ 11.没变.

{
 "cmd": ["g++", "-std=c++11", "${file}", "-o", "${file_path}/${file_base_name}"],
 "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
 "working_dir": "${file_path}",
 "selector": "source.c, source.c++",
 "variants":
 [
   {
     "name": "Run",
     "cmd":["bash", "-c", "g++ -std=c++11 '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
   }
 ]
}
Run Code Online (Sandbox Code Playgroud)

T.C*_*.C. 5

看起来g++你的计算机上的Clang版本(假装为Mac上的常见设置)默认仍然使用libstdc ++(GCC的C++标准库).libstdc++OS X附带的版本很古老,并且没有C++ 11支持(并且std::stod是C++ 11的补充).

传递-stdlib=libc++给您的编译器,使其使用Clang的标准库.