Implemented std::hash<wxString> specialization

Thanks to that wxString objects can be stored in certain
STL containers, e.g. unordered_map.
This commit is contained in:
Maciej Suminski 2017-12-12 17:45:45 +01:00
parent 124c82f1cf
commit 812b8b081d
2 changed files with 15 additions and 0 deletions

View File

@ -363,3 +363,9 @@ wxString GetOSXKicadDataDir()
return ddir.GetPath();
}
#endif
size_t std::hash<wxString>::operator()( const wxString& s ) const
{
return std::hash<std::wstring>{}( s.ToStdWstring() );
}

View File

@ -337,4 +337,13 @@ wxString GetOSXKicadMachineDataDir();
wxString GetOSXKicadDataDir();
#endif
///> Template specialization to enable wxStrings for certain containers (e.g. unordered_map)
namespace std
{
template<> struct hash<wxString>
{
size_t operator()( const wxString& s ) const;
};
}
#endif // INCLUDE__COMMON_H_