STL映射实例化

Yol*_*ola 1 c++ stl

有下一个代码:

class GameTexture
{
private:
LPDIRECT3DTEXTURE9 texture;
unsigned char *alphaLayer;
UINT width, height;

GameTexture() {};
GameTexture(const GameTexture&) {}
public:
static GameTexture *CreateTexture(LPCTSTR  pSrcFile, LPDIRECT3DDEVICE9 d3dDevice);

~GameTexture();
};

class TexturesPool
{
private:
map<string, GameTexture*> textures;
Run Code Online (Sandbox Code Playgroud)

并得到了下一个

1>c:\program files\microsoft visual studio 10.0\vc\include\xfunctional(125): 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'
1>          c:\program files\microsoft visual studio 10.0\vc\include\xtree(1885) : see declaration of 'std::operator <'
1>          c:\program files\microsoft visual studio 10.0\vc\include\xfunctional(124) : while compiling class template member function 'bool std::less<_Ty>::operator ()(const _Ty &,const _Ty &) const'
1>          with
1>          [
1>              _Ty=std::string
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\map(71) : see reference to class template instantiation 'std::less<_Ty>' being compiled
1>          with
1>          [
1>              _Ty=std::string
1>          ]
............
Run Code Online (Sandbox Code Playgroud)

Cub*_*bbi 9

你可能#include <string>遗漏了operator<应该宣布失踪的地方.

一些MSVC的头文件正向声明std :: string,但实际上并不包括<string>它自己.