Unordered_set TCHAR * requirements?

I want to use a data structure that serves as a .Net HashSet, I tried using unordered_set with the default hashing method and user mapping as follows:

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;

the problem is that when I tried to use a HashtSet to search for a specific key (using the method find) that I just added with insert, it returns HashSet::end()!!

Could you explain what the problem is? I am using VC ++ under VS2010

+3
source share
1 answer

, hash std::hash, std::hash char* wchar* , , .

, TCHAR* -, , , , --.

std::hash string wstring, , , , _UNICODE. " ", TCHAR * string wstring, - , .

, string wstring -, . unordered_set, , . , , , .

, .

+1

Source: https://habr.com/ru/post/1776891/


All Articles