<string> MinGW上的标头缺少很多功能

时间:2018-05-21 20:43:13

标签: c++ string gcc mingw std

在MinGW 5.4.1 + GCC 4.7.2上,-std=c++11中定义的某些功能缺失。例如,以下无法使用#include <string> #include <iostream> int main(int,char**){ //[Error] 'to_string' is not a member of 'std' std::cout << std::to_string(10); std::string s = "12"; //[Error] 'stoi' is not a member of 'std' std::cout << std::stoi(s); } 进行编译:

var myStrings = {
    a: "myStringA${test}",
    b: "Name: ${name}, Id: ${id}",
	
    getString: function(index, o) {
      var string = this[index];

      Object.keys(o).forEach(function(key) {
        if (string.indexOf("${" + key + "}")) {
	      string = string.replace("${" + key + "}", o[key]);
        }
      });

      return string;
    },
};

console.log(
  myStrings.getString("a", {test: "Cat"}),
  " ",
  myStrings.getString("b", {name: "Arber", id: 123})
);

// "myStringACat"
// "Name: Arber, Id: 123"

为什么会这样?这些功能在c ++ 11中定义,为什么它们不受支持?我可以让他们回来,还是我必须自己写?

谢谢!

0 个答案:

没有答案