카테고리 없음

std::map <std::wstring, std::wstring>에러

좋은나무 2008. 5. 8. 16:36
map 에서 wstring, string 을 키값으로 사용할 때 발생가능한 에러
작성일 : 2008-05-08
--------

    std::map <std::wstring, std::wstring> m1;
   typedef std::pair <std::wstring, std::wstring> wstring_pair; // <-- 에러 발생 시점
   m1.insert ( wstring_pair ( L"key", L"value" ) );

또는

    std::map <std::string, std::string> m1;
   typedef std::pair <std::string, std::string> string_pair; // <-- 에러 발생 시점
   m1.insert ( string_pair ( "key", "value" ) );

에서

오류    1    error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : 'const std::_Tree<_Traits> &'의 템플릿 인수를 'const std::wstring'에서 추론할 수 없습니다.    c:\program files\microsoft visual studio 8\vc\include\functional    143

또는

오 류    1    error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : 'const std::_Tree<_Traits> &'의 템플릿 인수를 'const std::string'에서 추론할 수 없습니다.    c:\program files\microsoft visual studio 8\vc\include\functional    143

이런 에러 발생시...

원인 및 해결책

#include <string> 이 선언되지 않았음. 소스코드에 추가할 것.