代码之家  ›  专栏  ›  技术社区  ›  Ahmed

无序的TChar*需求集?

  •  3
  • Ahmed  · 技术社区  · 14 年前

    我想使用类似于.NET哈希集的数据结构,我尝试使用无序的哈希集和默认的哈希方法和自定义比较器,如下所示:

    struct comparer
        {
            bool operator()( const TCHAR* first,const TCHAR* second) const
            {   
                return _tcscmp((TCHAR*)first,(TCHAR*)second) == 0;
            }
        };
    
        typedef unordered_set<const TCHAR*,hash<const TCHAR*>,comparer> HashSet;
    

    问题是当我试图使用hashtset查找特定的密钥时(使用 find 方法)我刚刚用 insert 它返回 HashSet::end() !!

    你能解释一下问题是什么吗? 我正在使用VS2010下的VC++

    1 回复  |  直到 14 年前
        1
  •  1
  •   Steve Jessop    14 年前

    hash std::hash char* wchar*

    TCHAR*

    string wstring _UNICODE

    推荐文章