C++ C++;地图可以';t成对插入

C++ C++;地图可以';t成对插入,c++,dictionary,visual-studio-2008,insert,C++,Dictionary,Visual Studio 2008,Insert,为什么我不能按如下所示插入 #include <map> struct something { } some_object; typedef std::map<std::string, something*> list; typedef std::pair<std::string, something*> pair; int main() { list l; pair p("abc", &some_object); // wor

为什么我不能按如下所示插入

#include <map>

struct something {

} some_object;

typedef std::map<std::string, something*> list;
typedef std::pair<std::string, something*> pair;

int main()
{
    list l;
    pair p("abc", &some_object); // working fine!!!
    l.insert(p); // 17 errors

    return 0;
}
#包括
构造某物{
}有人反对;
typedef std::映射列表;
typedef std::对;
int main()
{
清单l;
配对p(“abc”和某些对象);//工作正常!!!
l、 插入(p);//17个错误
返回0;
}
VisualStudio给了我很多错误,我什么都不懂。第一个是:

error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string'
错误C2784:'bool std::operator您需要

#include <string>
#包括
您需要

#include <string>
#包括

我想更改这一行:

typedef std::pair<std::string, something*> pair;

PS.“list”不是我放在全局命名空间中的类型名称的第一选择。要么把它放在自己的命名空间中,要么称它为“MyList”

我想更改这一行:

typedef std::pair<std::string, something*> pair;

PS.“list”不是我放在全局命名空间中的类型名称的第一选择。要么把它放在自己的命名空间中,要么称它为“MyList”

哇。。。这么快,这么愚蠢的错误。。我没有意识到这个错误。。但为什么这件简单的事情会出现17个错误呢我更惊讶的是,在抱怨一个模板错误之前,它让其他几个对std::string的引用编译了。如果它不能在字符串上执行运算符<,那么它就不能在Y上执行X,然后在Z上执行Y,等等……嗯,gcc在第7行中加上:“字符串不是std的成员”。更清楚了。哇。。。这么快,这么愚蠢的错误。。我没有意识到这个错误。。但为什么这件简单的事情会出现17个错误呢我更惊讶的是,在抱怨一个模板错误之前,它让其他几个对std::string的引用编译了。如果它不能在字符串上执行运算符<,那么它就不能在Y上执行X,然后在Z上执行Y,等等……嗯,gcc在第7行中加上:“字符串不是std的成员”。更清楚了。你用了“不能”而不是“不能”,这是我最讨厌的一个词。“不能”这个词本身就是一个词,它的意思与“不能”完全不同:。你用“不能”而不是“不能”,偶然发现了我最讨厌的一个词。“不能”本身就是一个词,与“不能”有完全不同的含义:。