1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-11 17:13:37 +02:00

Move definition of std::hash< wxString >

This commit is contained in:
Paul Licameli
2019-02-28 12:22:25 -05:00
parent 74128156bf
commit 961882838f
6 changed files with 23 additions and 16 deletions

View File

@@ -46,9 +46,27 @@
#include <type_traits>
#include <vector>
#include <wx/debug.h> // for wxASSERT
#include <wx/string.h> // type used in inline function
#include <wx/version.h> // for wxCHECK_VERSION
class wxString;
#if !wxCHECK_VERSION(3, 1, 0)
// For using std::unordered_map on wxString
namespace std
{
template<typename T> struct hash;
template<> struct hash< wxString > {
size_t operator () (const wxString &str) const // noexcept
{
auto stdstr = str.ToStdWstring(); // no allocations, a cheap fetch
using Hasher = hash< decltype(stdstr) >;
return Hasher{}( stdstr );
}
};
}
#endif
// ----------------------------------------------------------------------------
// TODO: I'd imagine this header may be replaced by other public headers. But,
// to try and minimize more changes to the base code, we can use this