第二行匹配到了 operator=(char) 的重载,实际上执行了 a["hello"] = '\1';
而构造函数没有单个 char 或单个整数类型的的重载。
这个确实是 std::string 的一个常见的坑
【 在 stub 的大作中提到: 】
: std::map<std::string, std::string> a;
: std::string m = 2; //编译失败
: a["hello"] = 1; //编译成功
: ...................
--
FROM 14.116.239.*