mirror of
https://github.com/cookiengineer/audacity
synced 2026-01-21 16:25:46 +01:00
Move definition of std::hash< wxString >
This commit is contained in:
@@ -46,9 +46,27 @@
|
|||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <wx/debug.h> // for wxASSERT
|
#include <wx/debug.h> // for wxASSERT
|
||||||
|
#include <wx/string.h> // type used in inline function
|
||||||
|
#include <wx/version.h> // for wxCHECK_VERSION
|
||||||
|
|
||||||
class wxString;
|
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,
|
// 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
|
// 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 <wx/mstream.h> // member variables
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include "audacity/Types.h"
|
||||||
|
|
||||||
class wxFFile;
|
class wxFFile;
|
||||||
class AudacityProject;
|
class AudacityProject;
|
||||||
|
|||||||
@@ -33,6 +33,8 @@
|
|||||||
#include "Audacity.h"
|
#include "Audacity.h"
|
||||||
#include "Languages.h"
|
#include "Languages.h"
|
||||||
|
|
||||||
|
#include "audacity/Types.h"
|
||||||
|
|
||||||
#include <wx/defs.h>
|
#include <wx/defs.h>
|
||||||
#include <wx/intl.h>
|
#include <wx/intl.h>
|
||||||
#include <wx/textfile.h>
|
#include <wx/textfile.h>
|
||||||
|
|||||||
@@ -637,22 +637,6 @@ make_iterator_range( const Container &container )
|
|||||||
return { container.begin(), container.end() };
|
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
|
// A utility function building a container of results
|
||||||
template< typename Container, typename Iterator, typename Function >
|
template< typename Container, typename Iterator, typename Function >
|
||||||
Container transform_range( Iterator first, Iterator last, Function &&fn )
|
Container transform_range( Iterator first, Iterator last, Function &&fn )
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
#include "widgets/wxPanelWrapper.h" // to inherit
|
#include "widgets/wxPanelWrapper.h" // to inherit
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include "audacity/Types.h"
|
||||||
|
|
||||||
class wxArrayString;
|
class wxArrayString;
|
||||||
class wxComboBox;
|
class wxComboBox;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ LRN
|
|||||||
#include "../FileNames.h"
|
#include "../FileNames.h"
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include "audacity/Types.h"
|
||||||
|
|
||||||
class wxArrayStringEx;
|
class wxArrayStringEx;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user