Stop testing for pre-standard hash map/set classes
Always use std::unordered_{map,set} when we use them at all, don't
bother with checking for their availability and with tr1 or even older
alternatives.
This commit is contained in:
parent
a0ae0cd316
commit
86348a9d28
10 changed files with 21 additions and 258 deletions
|
|
@ -132,38 +132,6 @@ if(NOT MSVC)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
wx_check_cxx_source_compiles("
|
||||
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;"
|
||||
HAVE_HASH_MAP
|
||||
hash_map hash_set
|
||||
)
|
||||
set(HAVE_STD_HASH_MAP ${HAVE_HASH_MAP})
|
||||
|
||||
wx_check_cxx_source_compiles("
|
||||
__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;"
|
||||
HAVE_EXT_HASH_MAP
|
||||
ext/hash_map ext/hash_set
|
||||
)
|
||||
set(HAVE_GNU_CXX_HASH_MAP ${HAVE_EXT_HASH_MAP})
|
||||
|
||||
wx_check_cxx_source_compiles("
|
||||
std::unordered_map<double*, char*> test1;
|
||||
std::unordered_set<char*> test2;"
|
||||
HAVE_STD_UNORDERED_MAP
|
||||
unordered_map unordered_set
|
||||
)
|
||||
set(HAVE_STD_UNORDERED_SET ${HAVE_STD_UNORDERED_MAP})
|
||||
|
||||
wx_check_cxx_source_compiles("
|
||||
std::tr1::unordered_map<double*, char*> test1;
|
||||
std::tr1::unordered_set<char*> test2;"
|
||||
HAVE_TR1_UNORDERED_MAP
|
||||
tr1/unordered_map tr1/unordered_set
|
||||
)
|
||||
set(HAVE_TR1_UNORDERED_SET ${HAVE_TR1_UNORDERED_MAP})
|
||||
|
||||
# Check for availability of GCC's atomic operations builtins.
|
||||
wx_check_c_source_compiles("
|
||||
unsigned int value=0;
|
||||
|
|
|
|||
|
|
@ -741,43 +741,6 @@
|
|||
*/
|
||||
#cmakedefine VA_LIST_IS_ARRAY 1
|
||||
|
||||
/*
|
||||
* Define if your compiler has <hash_map>
|
||||
*/
|
||||
#cmakedefine HAVE_HASH_MAP 1
|
||||
/*
|
||||
* Define if your compiler has <ext/hash_map>
|
||||
*/
|
||||
#cmakedefine HAVE_EXT_HASH_MAP 1
|
||||
/*
|
||||
* Define if your compiler has std::hash_map/hash_set
|
||||
*/
|
||||
#cmakedefine HAVE_STD_HASH_MAP 1
|
||||
/*
|
||||
* Define if your compiler has __gnu_cxx::hash_map/hash_set
|
||||
*/
|
||||
#cmakedefine HAVE_GNU_CXX_HASH_MAP 1
|
||||
|
||||
/*
|
||||
* Define if your compiler has std::unordered_map
|
||||
*/
|
||||
#cmakedefine HAVE_STD_UNORDERED_MAP 1
|
||||
|
||||
/*
|
||||
* Define if your compiler has std::unordered_set
|
||||
*/
|
||||
#cmakedefine HAVE_STD_UNORDERED_SET 1
|
||||
|
||||
/*
|
||||
* Define if your compiler has std::tr1::unordered_map
|
||||
*/
|
||||
#cmakedefine HAVE_TR1_UNORDERED_MAP 1
|
||||
|
||||
/*
|
||||
* Define if your compiler has std::tr1::unordered_set
|
||||
*/
|
||||
#cmakedefine HAVE_TR1_UNORDERED_SET 1
|
||||
|
||||
/*
|
||||
* Define if the compiler supports simple visibility declarations.
|
||||
*/
|
||||
|
|
|
|||
4
configure
vendored
4
configure
vendored
|
|
@ -24728,10 +24728,6 @@ if test "x$COMPAQCXX" = "xyes"; then
|
|||
CXXFLAGS="-w0 -msg_disable basclsnondto,unrimpret,intconlosbit"
|
||||
fi
|
||||
|
||||
$as_echo "#define HAVE_STD_UNORDERED_MAP 1" >>confdefs.h
|
||||
|
||||
$as_echo "#define HAVE_STD_UNORDERED_SET 1" >>confdefs.h
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1880,9 +1880,6 @@ if test "x$COMPAQCXX" = "xyes"; then
|
|||
CXXFLAGS="-w0 -msg_disable basclsnondto,unrimpret,intconlosbit"
|
||||
fi
|
||||
|
||||
AC_DEFINE(HAVE_STD_UNORDERED_MAP)
|
||||
AC_DEFINE(HAVE_STD_UNORDERED_SET)
|
||||
|
||||
dnl check for atomic operations builtins for wx/atomic.h:
|
||||
WX_ATOMIC_BUILTINS
|
||||
|
||||
|
|
|
|||
|
|
@ -315,13 +315,6 @@ typedef short int WXTYPE;
|
|||
/* for consistency with wxStatic/DynamicCast defined in wx/object.h */
|
||||
#define wxConstCast(obj, className) const_cast<className *>(obj)
|
||||
|
||||
#ifndef HAVE_STD_UNORDERED_MAP
|
||||
#define HAVE_STD_UNORDERED_MAP
|
||||
#endif
|
||||
#ifndef HAVE_STD_UNORDERED_SET
|
||||
#define HAVE_STD_UNORDERED_SET
|
||||
#endif
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* provide replacement for C99 va_copy() if the compiler doesn't have it */
|
||||
|
|
|
|||
|
|
@ -14,51 +14,14 @@
|
|||
#include "wx/string.h"
|
||||
#include "wx/wxcrt.h"
|
||||
|
||||
// In wxUSE_STD_CONTAINERS 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 wxUSE_STD_CONTAINERS
|
||||
|
||||
#if (defined(HAVE_EXT_HASH_MAP) || defined(HAVE_HASH_MAP)) \
|
||||
&& (defined(HAVE_GNU_CXX_HASH_MAP) || defined(HAVE_STD_HASH_MAP))
|
||||
#define HAVE_STL_HASH_MAP
|
||||
#endif
|
||||
|
||||
#if wxUSE_STD_CONTAINERS && \
|
||||
(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
|
||||
#include <unordered_map>
|
||||
|
||||
#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
|
||||
typedef std::unordered_map< KEY_T, VALUE_T, HASH_T, KEY_EQ_T > CLASSNAME
|
||||
|
||||
#elif wxUSE_STD_CONTAINERS && defined(HAVE_STL_HASH_MAP)
|
||||
|
||||
#if defined(HAVE_EXT_HASH_MAP)
|
||||
#include <ext/hash_map>
|
||||
#elif defined(HAVE_HASH_MAP)
|
||||
#include <hash_map>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_GNU_CXX_HASH_MAP)
|
||||
#define WX_HASH_MAP_NAMESPACE __gnu_cxx
|
||||
#elif defined(HAVE_STD_HASH_MAP)
|
||||
#define WX_HASH_MAP_NAMESPACE std
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
||||
#else // !wxUSE_STD_CONTAINERS || no std::{hash,unordered}_map class available
|
||||
#else // !wxUSE_STD_CONTAINERS
|
||||
|
||||
#define wxNEEDS_WX_HASH_MAP
|
||||
|
||||
|
|
@ -472,12 +435,12 @@ inline bool grow_lf70( size_t buckets, size_t items )
|
|||
struct WXDLLIMPEXP_BASE wxIntegerHash
|
||||
{
|
||||
private:
|
||||
WX_HASH_MAP_NAMESPACE::hash<long> longHash;
|
||||
WX_HASH_MAP_NAMESPACE::hash<unsigned long> ulongHash;
|
||||
WX_HASH_MAP_NAMESPACE::hash<int> intHash;
|
||||
WX_HASH_MAP_NAMESPACE::hash<unsigned int> uintHash;
|
||||
WX_HASH_MAP_NAMESPACE::hash<short> shortHash;
|
||||
WX_HASH_MAP_NAMESPACE::hash<unsigned short> ushortHash;
|
||||
std::hash<long> longHash;
|
||||
std::hash<unsigned long> ulongHash;
|
||||
std::hash<int> intHash;
|
||||
std::hash<unsigned int> uintHash;
|
||||
std::hash<short> shortHash;
|
||||
std::hash<unsigned short> ushortHash;
|
||||
|
||||
#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
|
||||
// hash<wxLongLong_t> ought to work but doesn't on some compilers
|
||||
|
|
@ -489,9 +452,9 @@ private:
|
|||
longHash( wx_truncate_cast(long, x >> (sizeof(long) * 8)) );
|
||||
}
|
||||
#elif defined SIZEOF_LONG_LONG && SIZEOF_LONG_LONG == SIZEOF_LONG
|
||||
WX_HASH_MAP_NAMESPACE::hash<long> longlongHash;
|
||||
std::hash<long> longlongHash;
|
||||
#else
|
||||
WX_HASH_MAP_NAMESPACE::hash<wxLongLong_t> longlongHash;
|
||||
std::hash<wxLongLong_t> longlongHash;
|
||||
#endif
|
||||
#endif // wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
|
||||
|
||||
|
|
|
|||
|
|
@ -16,79 +16,40 @@
|
|||
// see comment in wx/hashmap.h which also applies to different standard hash
|
||||
// set classes
|
||||
|
||||
#if wxUSE_STD_CONTAINERS && \
|
||||
(defined(HAVE_STD_UNORDERED_SET) || defined(HAVE_TR1_UNORDERED_SET))
|
||||
#if wxUSE_STD_CONTAINERS
|
||||
|
||||
#if defined(HAVE_STD_UNORDERED_SET)
|
||||
#include <unordered_set>
|
||||
#define WX_HASH_SET_BASE_TEMPLATE std::unordered_set
|
||||
#elif defined(HAVE_TR1_UNORDERED_SET)
|
||||
#include <tr1/unordered_set>
|
||||
#define WX_HASH_SET_BASE_TEMPLATE std::tr1::unordered_set
|
||||
#else
|
||||
#error Update this code: unordered_set is available, but I do not know where.
|
||||
#endif
|
||||
|
||||
#elif wxUSE_STD_CONTAINERS && defined(HAVE_STL_HASH_MAP)
|
||||
|
||||
#if defined(HAVE_EXT_HASH_MAP)
|
||||
#include <ext/hash_set>
|
||||
#elif defined(HAVE_HASH_MAP)
|
||||
#include <hash_set>
|
||||
#endif
|
||||
|
||||
#define WX_HASH_SET_BASE_TEMPLATE WX_HASH_MAP_NAMESPACE::hash_set
|
||||
|
||||
#endif // different hash_set/unordered_set possibilities
|
||||
|
||||
#ifdef WX_HASH_SET_BASE_TEMPLATE
|
||||
#include <unordered_set>
|
||||
|
||||
// we need to define the class declared by _WX_DECLARE_HASH_SET as a class and
|
||||
// not a typedef to allow forward declaring it
|
||||
#define _WX_DECLARE_HASH_SET_IMPL( KEY_T, HASH_T, KEY_EQ_T, PTROP, CLASSNAME, CLASSEXP ) \
|
||||
CLASSEXP CLASSNAME \
|
||||
: public WX_HASH_SET_BASE_TEMPLATE< KEY_T, HASH_T, KEY_EQ_T > \
|
||||
: public std::unordered_set< KEY_T, HASH_T, KEY_EQ_T > \
|
||||
{ \
|
||||
public: \
|
||||
explicit CLASSNAME(size_type n = 3, \
|
||||
const hasher& h = hasher(), \
|
||||
const key_equal& ke = key_equal(), \
|
||||
const allocator_type& a = allocator_type()) \
|
||||
: WX_HASH_SET_BASE_TEMPLATE< KEY_T, HASH_T, KEY_EQ_T >(n, h, ke, a) \
|
||||
: std::unordered_set< KEY_T, HASH_T, KEY_EQ_T >(n, h, ke, a) \
|
||||
{} \
|
||||
template <class InputIterator> \
|
||||
CLASSNAME(InputIterator f, InputIterator l, \
|
||||
const hasher& h = hasher(), \
|
||||
const key_equal& ke = key_equal(), \
|
||||
const allocator_type& a = allocator_type()) \
|
||||
: WX_HASH_SET_BASE_TEMPLATE< KEY_T, HASH_T, KEY_EQ_T >(f, l, h, ke, a)\
|
||||
: std::unordered_set< KEY_T, HASH_T, KEY_EQ_T >(f, l, h, ke, a) \
|
||||
{} \
|
||||
CLASSNAME(const WX_HASH_SET_BASE_TEMPLATE< KEY_T, HASH_T, KEY_EQ_T >& s) \
|
||||
: WX_HASH_SET_BASE_TEMPLATE< KEY_T, HASH_T, KEY_EQ_T >(s) \
|
||||
CLASSNAME(const std::unordered_set< KEY_T, HASH_T, KEY_EQ_T >& s) \
|
||||
: std::unordered_set< KEY_T, HASH_T, KEY_EQ_T >(s) \
|
||||
{} \
|
||||
}
|
||||
|
||||
// In some standard library implementations (in particular, the libstdc++ that
|
||||
// ships with g++ 4.7), std::unordered_set inherits privately from its hasher
|
||||
// and comparator template arguments for purposes of empty base optimization.
|
||||
// As a result, in the declaration of a class deriving from std::unordered_set
|
||||
// the names of the hasher and comparator classes are interpreted as naming
|
||||
// the base class which is inaccessible.
|
||||
// The workaround is to prefix the class names with 'struct'; however, don't
|
||||
// do this unconditionally, as with other compilers (both MSVC and clang)
|
||||
// doing it causes a warning if the class was declared as a 'class' rather than
|
||||
// a 'struct'.
|
||||
#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 7)
|
||||
#define WX_MAYBE_PREFIX_WITH_STRUCT(STRUCTNAME) struct STRUCTNAME
|
||||
#else
|
||||
#define WX_MAYBE_PREFIX_WITH_STRUCT(STRUCTNAME) STRUCTNAME
|
||||
#endif
|
||||
|
||||
#define _WX_DECLARE_HASH_SET( KEY_T, HASH_T, KEY_EQ_T, PTROP, CLASSNAME, CLASSEXP ) \
|
||||
_WX_DECLARE_HASH_SET_IMPL( \
|
||||
KEY_T, \
|
||||
WX_MAYBE_PREFIX_WITH_STRUCT(HASH_T), \
|
||||
WX_MAYBE_PREFIX_WITH_STRUCT(KEY_EQ_T), \
|
||||
HASH_T, \
|
||||
KEY_EQ_T, \
|
||||
PTROP, \
|
||||
CLASSNAME, \
|
||||
CLASSEXP)
|
||||
|
|
|
|||
|
|
@ -23,10 +23,6 @@
|
|||
|
||||
#define HAVE_VA_COPY 1
|
||||
#if __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 2 )
|
||||
#if !defined(__has_include)
|
||||
#define HAVE_TR1_UNORDERED_MAP 1
|
||||
#define HAVE_TR1_UNORDERED_SET 1
|
||||
#endif
|
||||
#define HAVE_GCC_ATOMIC_BUILTINS 1
|
||||
#endif
|
||||
#define HAVE_VISIBILITY 1
|
||||
|
|
|
|||
37
setup.h.in
37
setup.h.in
|
|
@ -741,43 +741,6 @@
|
|||
*/
|
||||
#undef VA_LIST_IS_ARRAY
|
||||
|
||||
/*
|
||||
* Define if your compiler has <hash_map>
|
||||
*/
|
||||
#undef HAVE_HASH_MAP
|
||||
/*
|
||||
* Define if your compiler has <ext/hash_map>
|
||||
*/
|
||||
#undef HAVE_EXT_HASH_MAP
|
||||
/*
|
||||
* Define if your compiler has std::hash_map/hash_set
|
||||
*/
|
||||
#undef HAVE_STD_HASH_MAP
|
||||
/*
|
||||
* Define if your compiler has __gnu_cxx::hash_map/hash_set
|
||||
*/
|
||||
#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
|
||||
|
||||
/*
|
||||
* Define if the compiler supports simple visibility declarations.
|
||||
*/
|
||||
|
|
|
|||
37
setup.h_vms
37
setup.h_vms
|
|
@ -807,43 +807,6 @@ typedef pid_t GPid;
|
|||
*/
|
||||
#undef VA_LIST_IS_ARRAY
|
||||
|
||||
/*
|
||||
* Define if your compiler has <hash_map>
|
||||
*/
|
||||
#undef HAVE_HASH_MAP
|
||||
/*
|
||||
* Define if your compiler has <ext/hash_map>
|
||||
*/
|
||||
#undef HAVE_EXT_HASH_MAP
|
||||
/*
|
||||
* Define if your compiler has std::hash_map/hash_set
|
||||
*/
|
||||
#undef HAVE_STD_HASH_MAP
|
||||
/*
|
||||
* Define if your compiler has __gnu_cxx::hash_map/hash_set
|
||||
*/
|
||||
#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
|
||||
|
||||
/*
|
||||
* Define if the compiler supports simple visibility declarations.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue