Move definition of std::hash< wxString >
This commit is contained in:
parent
74128156bf
commit
961882838f
|
@ -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
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <wx/mstream.h> // member variables
|
||||
|
||||
#include <unordered_map>
|
||||
#include "audacity/Types.h"
|
||||
|
||||
class wxFFile;
|
||||
class AudacityProject;
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include "Audacity.h"
|
||||
#include "Languages.h"
|
||||
|
||||
#include "audacity/Types.h"
|
||||
|
||||
#include <wx/defs.h>
|
||||
#include <wx/intl.h>
|
||||
#include <wx/textfile.h>
|
||||
|
|
|
@ -637,22 +637,6 @@ make_iterator_range( const Container &container )
|
|||
return { container.begin(), container.end() };
|
||||
}
|
||||
|
||||
#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
|
||||
|
||||
// A utility function building a container of results
|
||||
template< typename Container, typename Iterator, typename Function >
|
||||
Container transform_range( Iterator first, Iterator last, Function &&fn )
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "widgets/wxPanelWrapper.h" // to inherit
|
||||
|
||||
#include <unordered_map>
|
||||
#include "audacity/Types.h"
|
||||
|
||||
class wxArrayString;
|
||||
class wxComboBox;
|
||||
|
|
|
@ -21,6 +21,7 @@ LRN
|
|||
#include "../FileNames.h"
|
||||
|
||||
#include <unordered_map>
|
||||
#include "audacity/Types.h"
|
||||
|
||||
class wxArrayStringEx;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user