use tr1::unordered_{map,set} if available for wxHash{Map,Set} in STL build (#9532) [backport from trunk]

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@55215 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-08-23 18:54:04 +00:00
parent 60e82f36d3
commit 62b8f1fc35
6 changed files with 629 additions and 12 deletions

475
configure vendored
View File

@@ -1,5 +1,5 @@
#! /bin/sh #! /bin/sh
# From configure.in Id: configure.in 55027 2008-08-08 05:09:54Z RD . # From configure.in Id: configure.in 55211 2008-08-23 18:30:30Z VZ .
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.59 for wxWidgets 2.8.8. # Generated by GNU Autoconf 2.59 for wxWidgets 2.8.8.
# #
@@ -24115,6 +24115,479 @@ _ACEOF
_ACEOF _ACEOF
fi fi
echo "$as_me:$LINENO: checking for unordered_map" >&5
echo $ECHO_N "checking for unordered_map... $ECHO_C" >&6
if test "${ac_cv_header_unordered_map+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <unordered_map>
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_header_unordered_map=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_header_unordered_map=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $ac_cv_header_unordered_map" >&5
echo "${ECHO_T}$ac_cv_header_unordered_map" >&6
if test $ac_cv_header_unordered_map = yes; then
echo "$as_me:$LINENO: checking for unordered_map and unordered_set in std" >&5
echo $ECHO_N "checking for unordered_map and unordered_set in std... $ECHO_C" >&6
if test "${wx_cv_class_stdunorderedmapset+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <unordered_map>
#include <unordered_set>
int
main ()
{
std::unordered_map<double*, char*> test1;
std::unordered_set<char*> test2;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
wx_cv_class_stdunorderedmapset=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
wx_cv_class_stdunorderedmapset=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $wx_cv_class_stdunorderedmapset" >&5
echo "${ECHO_T}$wx_cv_class_stdunorderedmapset" >&6
fi
if test "$wx_cv_class_stdunorderedmapset" = yes; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_STD_UNORDERED_MAP 1
_ACEOF
cat >>confdefs.h <<\_ACEOF
#define HAVE_STD_UNORDERED_SET 1
_ACEOF
else
echo "$as_me:$LINENO: checking for tr1/unordered_map" >&5
echo $ECHO_N "checking for tr1/unordered_map... $ECHO_C" >&6
if test "${ac_cv_header_tr1_unordered_map+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <tr1/unordered_map>
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_header_tr1_unordered_map=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_header_tr1_unordered_map=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $ac_cv_header_tr1_unordered_map" >&5
echo "${ECHO_T}$ac_cv_header_tr1_unordered_map" >&6
if test $ac_cv_header_tr1_unordered_map = yes; then
echo "$as_me:$LINENO: checking for unordered_map and unordered_set in std::tr1" >&5
echo $ECHO_N "checking for unordered_map and unordered_set in std::tr1... $ECHO_C" >&6
if test "${wx_cv_class_tr1unorderedmapset+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <tr1/unordered_map>
#include <tr1/unordered_set>
int
main ()
{
std::tr1::unordered_map<double*, char*> test1;
std::tr1::unordered_set<char*> test2;
#if defined(__GNUC__) && (__GNUC__==4) && (__GNUC_MINOR__<2)
#error can't use unordered_{map,set} with gcc-4.[01]: http://gcc.gnu.org/PR24389
#endif
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
wx_cv_class_tr1unorderedmapset=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
wx_cv_class_tr1unorderedmapset=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $wx_cv_class_tr1unorderedmapset" >&5
echo "${ECHO_T}$wx_cv_class_tr1unorderedmapset" >&6
fi
if test "$wx_cv_class_tr1unorderedmapset" = yes; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_TR1_UNORDERED_MAP 1
_ACEOF
cat >>confdefs.h <<\_ACEOF
#define HAVE_TR1_UNORDERED_SET 1
_ACEOF
else
echo "$as_me:$LINENO: checking for hash_map" >&5
echo $ECHO_N "checking for hash_map... $ECHO_C" >&6
if test "${ac_cv_header_hash_map+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <hash_map>
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_header_hash_map=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_header_hash_map=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $ac_cv_header_hash_map" >&5
echo "${ECHO_T}$ac_cv_header_hash_map" >&6
if test $ac_cv_header_hash_map = yes; then
echo "$as_me:$LINENO: checking for std::hash_map and hash_set" >&5
echo $ECHO_N "checking for std::hash_map and hash_set... $ECHO_C" >&6
if test "${wx_cv_class_stdhashmapset+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <hash_map>
#include <hash_set>
int
main ()
{
std::hash_map<double*, char*, std::hash<double*>, std::equal_to<double*> > test1;
std::hash_set<char*, std::hash<char*>, std::equal_to<char*> > test2;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
wx_cv_class_stdhashmapset=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
wx_cv_class_stdhashmapset=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $wx_cv_class_stdhashmapset" >&5
echo "${ECHO_T}$wx_cv_class_stdhashmapset" >&6
fi
if test "$wx_cv_class_stdhashmapset" = yes; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_HASH_MAP 1
_ACEOF
cat >>confdefs.h <<\_ACEOF
#define HAVE_STD_HASH_MAP 1
_ACEOF
fi
echo "$as_me:$LINENO: checking for ext/hash_map" >&5
echo $ECHO_N "checking for ext/hash_map... $ECHO_C" >&6
if test "${ac_cv_header_ext_hash_map+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <ext/hash_map>
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_header_ext_hash_map=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_header_ext_hash_map=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $ac_cv_header_ext_hash_map" >&5
echo "${ECHO_T}$ac_cv_header_ext_hash_map" >&6
if test $ac_cv_header_ext_hash_map = yes; then
echo "$as_me:$LINENO: checking for GNU hash_map and hash_set" >&5
echo $ECHO_N "checking for GNU hash_map and hash_set... $ECHO_C" >&6
if test "${wx_cv_class_gnuhashmapset+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <ext/hash_map>
#include <ext/hash_set>
int
main ()
{
__gnu_cxx::hash_map<double*, char*, __gnu_cxx::hash<double*>, std::equal_to<double*> > test1;
__gnu_cxx::hash_set<char*, __gnu_cxx::hash<char*>, std::equal_to<char*> > test2;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
wx_cv_class_gnuhashmapset=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
wx_cv_class_gnuhashmapset=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $wx_cv_class_gnuhashmapset" >&5
echo "${ECHO_T}$wx_cv_class_gnuhashmapset" >&6
fi
fi
fi
fi fi
ac_ext=c ac_ext=c

View File

@@ -2540,6 +2540,86 @@ if test "$wxUSE_STL" = "yes"; then
AC_DEFINE(HAVE_EXT_HASH_MAP) AC_DEFINE(HAVE_EXT_HASH_MAP)
AC_DEFINE(HAVE_GNU_CXX_HASH_MAP) AC_DEFINE(HAVE_GNU_CXX_HASH_MAP)
fi fi
AC_CHECK_HEADER([unordered_map],
[AC_CACHE_CHECK([for unordered_map and unordered_set in std],
wx_cv_class_stdunorderedmapset,
[AC_TRY_COMPILE([#include <unordered_map>
#include <unordered_set>],
[std::unordered_map<double*, char*> test1;
std::unordered_set<char*> test2;],
wx_cv_class_stdunorderedmapset=yes,
wx_cv_class_stdunorderedmapset=no)
]
)],
[],
[ ]
)
if test "$wx_cv_class_stdunorderedmapset" = yes; then
AC_DEFINE(HAVE_STD_UNORDERED_MAP)
AC_DEFINE(HAVE_STD_UNORDERED_SET)
else
AC_CHECK_HEADER([tr1/unordered_map],
[AC_CACHE_CHECK([for unordered_map and unordered_set in std::tr1],
wx_cv_class_tr1unorderedmapset,
[AC_TRY_COMPILE([#include <tr1/unordered_map>
#include <tr1/unordered_set>],
[std::tr1::unordered_map<double*, char*> test1;
std::tr1::unordered_set<char*> test2;
#if defined(__GNUC__) && (__GNUC__==4) && (__GNUC_MINOR__<2)
#error can't use unordered_{map,set} with gcc-4.[01]: http://gcc.gnu.org/PR24389
#endif],
wx_cv_class_tr1unorderedmapset=yes,
wx_cv_class_tr1unorderedmapset=no)
]
)],
[],
[ ]
)
if test "$wx_cv_class_tr1unorderedmapset" = yes; then
AC_DEFINE(HAVE_TR1_UNORDERED_MAP)
AC_DEFINE(HAVE_TR1_UNORDERED_SET)
else
dnl check for hash_map and hash_set headers
AC_CHECK_HEADER([hash_map],
[AC_CACHE_CHECK([for std::hash_map and hash_set],
wx_cv_class_stdhashmapset,
[AC_TRY_COMPILE([#include <hash_map>
#include <hash_set>],
[std::hash_map<double*, char*, std::hash<double*>, std::equal_to<double*> > test1;
std::hash_set<char*, std::hash<char*>, std::equal_to<char*> > test2;],
wx_cv_class_stdhashmapset=yes,
wx_cv_class_stdhashmapset=no)
]
)],
[],
[ ]
)
if test "$wx_cv_class_stdhashmapset" = yes; then
AC_DEFINE(HAVE_HASH_MAP)
AC_DEFINE(HAVE_STD_HASH_MAP)
fi
AC_CHECK_HEADER([ext/hash_map],
[AC_CACHE_CHECK([for GNU hash_map and hash_set],
wx_cv_class_gnuhashmapset,
[AC_TRY_COMPILE([#include <ext/hash_map>
#include <ext/hash_set>],
[__gnu_cxx::hash_map<double*, char*, __gnu_cxx::hash<double*>, std::equal_to<double*> > test1;
__gnu_cxx::hash_set<char*, __gnu_cxx::hash<char*>, std::equal_to<char*> > test2;],
wx_cv_class_gnuhashmapset=yes,
wx_cv_class_gnuhashmapset=no)
]
)],
[],
[ ]
)
fi
fi
fi fi
dnl pop C++ dnl pop C++

View File

@@ -95,6 +95,9 @@ All:
- Optimize wxString::Replace() for single character arguments. - Optimize wxString::Replace() for single character arguments.
- Updated Hindi translation (Priyank Bolia). - Updated Hindi translation (Priyank Bolia).
- Use tr1::unordered_{map,set} for wxHash{Map,Set} implementation if available
in STL build; in particular do not use deprecated hash_{map,set} which
results in a lot of warnings from newer g++ (Jan Van Dijk and Pete Stieber).
All (GUI): All (GUI):

View File

@@ -14,12 +14,34 @@
#include "wx/string.h" #include "wx/string.h"
// In wxUSE_STL build we prefer to use the standard hash map class but it can
// be either in non-standard hash_map header (old g++ and some other STL
// implementations) or in C++0x standard unordered_map which can in turn be
// available either in std::tr1 or std namespace itself
//
// To summarize: if std::unordered_map is available use it, otherwise use tr1
// and finally fall back to non-standard hash_map
#if (defined(HAVE_EXT_HASH_MAP) || defined(HAVE_HASH_MAP)) \ #if (defined(HAVE_EXT_HASH_MAP) || defined(HAVE_HASH_MAP)) \
&& (defined(HAVE_GNU_CXX_HASH_MAP) || defined(HAVE_STD_HASH_MAP)) && (defined(HAVE_GNU_CXX_HASH_MAP) || defined(HAVE_STD_HASH_MAP))
#define HAVE_STL_HASH_MAP #define HAVE_STL_HASH_MAP
#endif #endif
#if wxUSE_STL && defined(HAVE_STL_HASH_MAP) #if wxUSE_STL && \
(defined(HAVE_STD_UNORDERED_MAP) || defined(HAVE_TR1_UNORDERED_MAP))
#if defined(HAVE_STD_UNORDERED_MAP)
#include <unordered_map>
#define WX_HASH_MAP_NAMESPACE std
#elif defined(HAVE_TR1_UNORDERED_MAP)
#include <tr1/unordered_map>
#define WX_HASH_MAP_NAMESPACE std::tr1
#endif
#define _WX_DECLARE_HASH_MAP( KEY_T, VALUE_T, HASH_T, KEY_EQ_T, CLASSNAME, CLASSEXP ) \
typedef WX_HASH_MAP_NAMESPACE::unordered_map< KEY_T, VALUE_T, HASH_T, KEY_EQ_T > CLASSNAME
#elif wxUSE_STL && defined(HAVE_STL_HASH_MAP)
#if defined(HAVE_EXT_HASH_MAP) #if defined(HAVE_EXT_HASH_MAP)
#include <ext/hash_map> #include <ext/hash_map>
@@ -36,8 +58,9 @@
#define _WX_DECLARE_HASH_MAP( KEY_T, VALUE_T, HASH_T, KEY_EQ_T, CLASSNAME, CLASSEXP ) \ #define _WX_DECLARE_HASH_MAP( KEY_T, VALUE_T, HASH_T, KEY_EQ_T, CLASSNAME, CLASSEXP ) \
typedef WX_HASH_MAP_NAMESPACE::hash_map< KEY_T, VALUE_T, HASH_T, KEY_EQ_T > CLASSNAME typedef WX_HASH_MAP_NAMESPACE::hash_map< KEY_T, VALUE_T, HASH_T, KEY_EQ_T > CLASSNAME
#else // !wxUSE_STL || !defined(HAVE_STL_HASH_MAP) #else // !wxUSE_STL || no std::{hash,unordered}_map class available
#define wxNEEDS_WX_HASH_MAP
#ifdef __WXWINCE__ #ifdef __WXWINCE__
typedef int ptrdiff_t; typedef int ptrdiff_t;
@@ -442,7 +465,7 @@ inline bool grow_lf70( size_t buckets, size_t items )
return float(items)/float(buckets) >= 0.85; return float(items)/float(buckets) >= 0.85;
} }
#endif // !wxUSE_STL || !defined(HAVE_STL_HASH_MAP) #endif // various hash map implementations
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// hashing and comparison functors // hashing and comparison functors
@@ -452,7 +475,7 @@ inline bool grow_lf70( size_t buckets, size_t items )
// operators to suppress warnings about "statement with no effect" from gcc // operators to suppress warnings about "statement with no effect" from gcc
// in the hash table class assignment operator (where they're assigned) // in the hash table class assignment operator (where they're assigned)
#if wxUSE_STL && defined(HAVE_STL_HASH_MAP) #ifndef wxNEEDS_WX_HASH_MAP
// integer types // integer types
class WXDLLIMPEXP_BASE wxIntegerHash class WXDLLIMPEXP_BASE wxIntegerHash
@@ -496,7 +519,7 @@ public:
wxIntegerHash& operator=(const wxIntegerHash&) { return *this; } wxIntegerHash& operator=(const wxIntegerHash&) { return *this; }
}; };
#else // !wxUSE_STL || !defined(HAVE_STL_HASH_MAP) #else // wxNEEDS_WX_HASH_MAP
// integer types // integer types
class WXDLLIMPEXP_BASE wxIntegerHash class WXDLLIMPEXP_BASE wxIntegerHash
@@ -517,7 +540,7 @@ public:
wxIntegerHash& operator=(const wxIntegerHash&) { return *this; } wxIntegerHash& operator=(const wxIntegerHash&) { return *this; }
}; };
#endif // !wxUSE_STL || !defined(HAVE_STL_HASH_MAP) #endif // !wxNEEDS_WX_HASH_MAP/wxNEEDS_WX_HASH_MAP
class WXDLLIMPEXP_BASE wxIntegerEqual class WXDLLIMPEXP_BASE wxIntegerEqual
{ {
@@ -543,8 +566,8 @@ class WXDLLIMPEXP_BASE wxPointerHash
public: public:
wxPointerHash() { } wxPointerHash() { }
#if wxUSE_STL && defined(HAVE_STL_HASH_MAP) #ifdef wxNEEDS_WX_HASH_MAP
size_t operator()( const void* k ) const { return (size_t)k; } wxUIntPtr operator()( const void* k ) const { return wxPtrToUInt(k); }
#else #else
wxUIntPtr operator()( const void* k ) const { return wxPtrToUInt(k); } wxUIntPtr operator()( const void* k ) const { return wxPtrToUInt(k); }
#endif #endif
@@ -596,7 +619,7 @@ public:
wxStringEqual& operator=(const wxStringEqual&) { return *this; } wxStringEqual& operator=(const wxStringEqual&) { return *this; }
}; };
#if !wxUSE_STL || !defined(HAVE_STL_HASH_MAP) #ifdef wxNEEDS_WX_HASH_MAP
#define _WX_DECLARE_HASH_MAP( KEY_T, VALUE_T, HASH_T, KEY_EQ_T, CLASSNAME, CLASSEXP ) \ #define _WX_DECLARE_HASH_MAP( KEY_T, VALUE_T, HASH_T, KEY_EQ_T, CLASSNAME, CLASSEXP ) \
_WX_DECLARE_PAIR( KEY_T, VALUE_T, CLASSNAME##_wxImplementation_Pair, CLASSEXP ) \ _WX_DECLARE_PAIR( KEY_T, VALUE_T, CLASSNAME##_wxImplementation_Pair, CLASSEXP ) \
@@ -655,7 +678,7 @@ public: \
} \ } \
} }
#endif // !wxUSE_STL || !defined(HAVE_STL_HASH_MAP) #endif // wxNEEDS_WX_HASH_MAP
// these macros are to be used in the user code // these macros are to be used in the user code
#define WX_DECLARE_HASH_MAP( KEY_T, VALUE_T, HASH_T, KEY_EQ_T, CLASSNAME) \ #define WX_DECLARE_HASH_MAP( KEY_T, VALUE_T, HASH_T, KEY_EQ_T, CLASSNAME) \

View File

@@ -14,7 +14,25 @@
#include "wx/hashmap.h" #include "wx/hashmap.h"
#if wxUSE_STL && defined(HAVE_STL_HASH_MAP) // see comment in wx/hashmap.h which also applies to different standard hash
// set classes
#if wxUSE_STL && \
(defined(HAVE_STD_UNORDERED_SET) || defined(HAVE_TR1_UNORDERED_SET))
#if defined(HAVE_STD_UNORDERED_SET)
#include <unordered_set>
#define _WX_DECLARE_HASH_SET( KEY_T, HASH_T, KEY_EQ_T, CLASSNAME, CLASSEXP )\
typedef std::unordered_set< KEY_T, HASH_T, KEY_EQ_T > CLASSNAME
#elif defined(HAVE_TR1_UNORDERED_SET)
#include <tr1/unordered_set>
#define _WX_DECLARE_HASH_SET( KEY_T, HASH_T, KEY_EQ_T, CLASSNAME, CLASSEXP )\
typedef std::tr1::unordered_set< KEY_T, HASH_T, KEY_EQ_T > CLASSNAME
#else
#error Update this code: unordered_set is available, but I do not know where.
#endif
#elif wxUSE_STL && defined(HAVE_STL_HASH_MAP)
#if defined(HAVE_EXT_HASH_MAP) #if defined(HAVE_EXT_HASH_MAP)
#include <ext/hash_set> #include <ext/hash_set>

View File

@@ -625,6 +625,26 @@
*/ */
#undef HAVE_GNU_CXX_HASH_MAP #undef HAVE_GNU_CXX_HASH_MAP
/*
* Define if your compiler has std::unordered_map
*/
#undef HAVE_STD_UNORDERED_MAP
/*
* Define if your compiler has std::unordered_set
*/
#undef HAVE_STD_UNORDERED_SET
/*
* Define if your compiler has std::tr1::unordered_map
*/
#undef HAVE_TR1_UNORDERED_MAP
/*
* Define if your compiler has std::tr1::unordered_set
*/
#undef HAVE_TR1_UNORDERED_SET
/* /*
* The built-in regex supports advanced REs in additional to POSIX's basic * The built-in regex supports advanced REs in additional to POSIX's basic
* and extended. Your system regex probably won't support this, and in this * and extended. Your system regex probably won't support this, and in this