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:
@@ -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
|
||||
|
Reference in New Issue
Block a user