From d53bd43d75f3bf4cab9ff29ab7f0322836ea93d1 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 4 Jul 2024 01:35:41 +0200 Subject: [PATCH] Declare a class in WX_DECLARE_HASH_MAP() too Instead of just using a type alias, define a class inheriting from std::unordered_map<> in this macro, as this makes it compatible with the existing code not using wxUSE_STD_CONTAINERS which forward-declares hash map classes. And as this was already done in WX_DECLARE_HASH_SET(), it's also more consistent. Closes #24674. --- include/wx/hashmap.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/wx/hashmap.h b/include/wx/hashmap.h index 4b540914a1..d32466dd15 100644 --- a/include/wx/hashmap.h +++ b/include/wx/hashmap.h @@ -25,8 +25,14 @@ #include +// Use inheritance instead of simple typedef to allow existing forward +// declarations of the hash map classes in the applications using wx to work. #define _WX_DECLARE_HASH_MAP( KEY_T, VALUE_T, HASH_T, KEY_EQ_T, CLASSNAME, CLASSEXP ) \ - typedef std::unordered_map< KEY_T, VALUE_T, HASH_T, KEY_EQ_T > CLASSNAME + class CLASSNAME : public std::unordered_map< KEY_T, VALUE_T, HASH_T, KEY_EQ_T > \ + { \ + public: \ + using std::unordered_map< KEY_T, VALUE_T, HASH_T, KEY_EQ_T >::unordered_map; \ + } #else // wxNEEDS_WX_HASH_MAP