diff options
author | Brad King <brad.king@kitware.com> | 2005-04-15 13:54:03 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2005-04-15 13:54:03 (GMT) |
commit | 6c68c8147532bbc07e467b6e80cbfbee07b99f26 (patch) | |
tree | 2748e864e7b3f90576e20153ee7eb53107938abe /Source/kwsys | |
parent | 4caefef37eb2f23948d915a6d33447ef4e6243c1 (diff) | |
download | CMake-6c68c8147532bbc07e467b6e80cbfbee07b99f26.zip CMake-6c68c8147532bbc07e467b6e80cbfbee07b99f26.tar.gz CMake-6c68c8147532bbc07e467b6e80cbfbee07b99f26.tar.bz2 |
ENH: Added KWSys try-compiles KWSYS_STL_HAS_ITERATOR_TRAITS, KWSYS_STL_HAS_ITERATOR_CATEGORY, KWSYS_STL_HAS___ITERATOR_CATEGORY, and KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE to get the hash table to compile on old HP and Sun compilers.
Diffstat (limited to 'Source/kwsys')
-rw-r--r-- | Source/kwsys/CMakeLists.txt | 30 | ||||
-rw-r--r-- | Source/kwsys/Configure.hxx.in | 16 | ||||
-rw-r--r-- | Source/kwsys/hash_map.hxx.in | 4 | ||||
-rw-r--r-- | Source/kwsys/hash_set.hxx.in | 4 | ||||
-rw-r--r-- | Source/kwsys/hashtable.hxx.in | 54 | ||||
-rw-r--r-- | Source/kwsys/kwsysPlatformCxxTests.cxx | 24 |
6 files changed, 113 insertions, 19 deletions
diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index 6423089..3e2dee8 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -182,10 +182,32 @@ SET(KWSYS_PLATFORM_CXX_TEST_DEFINES -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}) KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_STRING_HAVE_NEQ_CHAR "Checking whether stl string has operator!= for char*" DIRECT) -KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_REBIND - "Checking for rebind member of stl allocator" DIRECT) -KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT - "Checking for non-standard argument to stl allocator<>::max_size" DIRECT) +KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ITERATOR_TRAITS + "Checking whether stl has iterator_traits" DIRECT) +IF(KWSYS_STL_HAS_ITERATOR_TRAITS) + SET(KWSYS_STL_HAS_ITERATOR_CATEGORY 0) + SET(KWSYS_STL_HAS___ITERATOR_CATEGORY 0) +ELSE(KWSYS_STL_HAS_ITERATOR_TRAITS) + KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ITERATOR_CATEGORY + "Checking whether stl has old iterator_category" DIRECT) + IF(KWSYS_STL_HAS_ITERATOR_CATEGORY) + SET(KWSYS_STL_HAS___ITERATOR_CATEGORY 0) + ELSE(KWSYS_STL_HAS_ITERATOR_CATEGORY) + KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS___ITERATOR_CATEGORY + "Checking whether stl has internal __iterator_category" DIRECT) + ENDIF(KWSYS_STL_HAS_ITERATOR_CATEGORY) +ENDIF(KWSYS_STL_HAS_ITERATOR_TRAITS) +KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE + "Checking whether stl has old non-template allocator" DIRECT) +IF(KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE) + SET(KWSYS_STL_HAS_ALLOCATOR_REBIND 0) + SET(KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT 0) +ELSE(KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE) + KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_REBIND + "Checking for rebind member of stl allocator" DIRECT) + KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT + "Checking for non-standard argument to stl allocator<>::max_size" DIRECT) +ENDIF(KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE) IF(KWSYS_IOS_USE_ANSI) # ANSI streams always have string operators. SET(KWSYS_STL_STRING_HAVE_OSTREAM 1) diff --git a/Source/kwsys/Configure.hxx.in b/Source/kwsys/Configure.hxx.in index 3cddb34..5b9268c 100644 --- a/Source/kwsys/Configure.hxx.in +++ b/Source/kwsys/Configure.hxx.in @@ -96,6 +96,18 @@ # define @KWSYS_NAMESPACE@_CXX_DECL_TYPENAME typename #endif +/* Whether the stl has iterator_traits. */ +#define @KWSYS_NAMESPACE@_STL_HAS_ITERATOR_TRAITS @KWSYS_STL_HAS_ITERATOR_TRAITS@ + +/* Whether the stl has iterator_category. */ +#define @KWSYS_NAMESPACE@_STL_HAS_ITERATOR_CATEGORY @KWSYS_STL_HAS_ITERATOR_CATEGORY@ + +/* Whether the stl has __iterator_category. */ +#define @KWSYS_NAMESPACE@_STL_HAS___ITERATOR_CATEGORY @KWSYS_STL_HAS___ITERATOR_CATEGORY@ + +/* Whether the stl allocator is not a template. */ +#define @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_NONTEMPLATE @KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE@ + /* Whether the stl allocator has rebind. */ #define @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_REBIND @KWSYS_STL_HAS_ALLOCATOR_REBIND@ @@ -132,6 +144,10 @@ # define KWSYS_STL_HAS_ALLOCATOR_REBIND @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_REBIND # define KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT # define KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP @KWSYS_NAMESPACE@_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP +# define KWSYS_STL_HAS_ITERATOR_TRAITS @KWSYS_NAMESPACE@_STL_HAS_ITERATOR_TRAITS +# define KWSYS_STL_HAS_ITERATOR_CATEGORY @KWSYS_NAMESPACE@_STL_HAS_ITERATOR_CATEGORY +# define KWSYS_STL_HAS___ITERATOR_CATEGORY @KWSYS_NAMESPACE@_STL_HAS___ITERATOR_CATEGORY +# define KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_NONTEMPLATE #endif #endif diff --git a/Source/kwsys/hash_map.hxx.in b/Source/kwsys/hash_map.hxx.in index d0ff1bd..e73080a 100644 --- a/Source/kwsys/hash_map.hxx.in +++ b/Source/kwsys/hash_map.hxx.in @@ -71,7 +71,7 @@ struct hash_select1st: template <class _Key, class _Tp, class _HashFcn = hash<_Key>, class _EqualKey = kwsys_stl::equal_to<_Key>, - class _Alloc = kwsys_stl::allocator<char> > + class _Alloc = @KWSYS_NAMESPACE@_HASH_DEFAULT_ALLOCATOR(char) > class hash_map; template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc> @@ -263,7 +263,7 @@ swap(hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1, template <class _Key, class _Tp, class _HashFcn = hash<_Key>, class _EqualKey = kwsys_stl::equal_to<_Key>, - class _Alloc = kwsys_stl::allocator<char> > + class _Alloc = @KWSYS_NAMESPACE@_HASH_DEFAULT_ALLOCATOR(char) > class hash_multimap; template <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc> diff --git a/Source/kwsys/hash_set.hxx.in b/Source/kwsys/hash_set.hxx.in index e627f5d..554e31b 100644 --- a/Source/kwsys/hash_set.hxx.in +++ b/Source/kwsys/hash_set.hxx.in @@ -69,7 +69,7 @@ struct _Identity : public kwsys_stl::unary_function<_Tp,_Tp> template <class _Value, class _HashFcn = hash<_Value>, class _EqualKey = kwsys_stl::equal_to<_Value>, - class _Alloc = kwsys_stl::allocator<char> > + class _Alloc = @KWSYS_NAMESPACE@_HASH_DEFAULT_ALLOCATOR(char) > class hash_set; template <class _Value, class _HashFcn, class _EqualKey, class _Alloc> @@ -257,7 +257,7 @@ swap(hash_set<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1, template <class _Value, class _HashFcn = hash<_Value>, class _EqualKey = kwsys_stl::equal_to<_Value>, - class _Alloc = kwsys_stl::allocator<char> > + class _Alloc = @KWSYS_NAMESPACE@_HASH_DEFAULT_ALLOCATOR(char) > class hash_multiset; template <class _Val, class _HashFcn, class _EqualKey, class _Alloc> diff --git a/Source/kwsys/hashtable.hxx.in b/Source/kwsys/hashtable.hxx.in index cb2f19f..5d989d9 100644 --- a/Source/kwsys/hashtable.hxx.in +++ b/Source/kwsys/hashtable.hxx.in @@ -54,6 +54,12 @@ # pragma warning (disable:4786) #endif +#if @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_NONTEMPLATE +# define @KWSYS_NAMESPACE@_HASH_DEFAULT_ALLOCATOR(T) kwsys_stl::allocator +#else +# define @KWSYS_NAMESPACE@_HASH_DEFAULT_ALLOCATOR(T) kwsys_stl::allocator< T > +#endif + namespace @KWSYS_NAMESPACE@ { @@ -72,8 +78,13 @@ class hash_allocator: public hash_allocator_base private: // Store the real allocator privately. typedef Alloc alloc_type; +#if @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_NONTEMPLATE + typedef char alloc_value_type; + typedef void* alloc_pointer; +#else typedef typename alloc_type::value_type alloc_value_type; typedef typename alloc_type::pointer alloc_pointer; +#endif alloc_type alloc_; public: @@ -97,11 +108,17 @@ public: # endif pointer address(reference x) const { return &x; } const_pointer address(const_reference x) const { return &x; } - pointer allocate(size_type n=1, kwsys_stl::allocator<void>::const_pointer hint = 0) +#if @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_NONTEMPLATE + typedef void* void_pointer; + typedef const void* const_void_pointer; +#else + typedef kwsys_stl::allocator<void>::pointer void_pointer; + typedef kwsys_stl::allocator<void>::const_pointer const_void_pointer; +#endif + pointer allocate(size_type n=1, const_void_pointer hint = 0) { if(n) { - typedef kwsys_stl::allocator<void>::pointer void_pointer; return static_cast<pointer>( static_cast<void*>( @@ -116,7 +133,12 @@ public: { if(n) { - alloc_.deallocate(static_cast<alloc_pointer>(static_cast<void*>(p)), n*chunk()); +#if @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_NONTEMPLATE + alloc_.deallocate(static_cast<alloc_pointer>(static_cast<void*>(p))); +#else + alloc_.deallocate(static_cast<alloc_pointer>(static_cast<void*>(p)), + n*chunk()); +#endif } } #if @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT @@ -151,7 +173,7 @@ struct _Hashtable_node template <class _Val, class _Key, class _HashFcn, class _ExtractKey, class _EqualKey, - class _Alloc = kwsys_stl::allocator<char> > + class _Alloc = @KWSYS_NAMESPACE@_HASH_DEFAULT_ALLOCATOR(char) > class hashtable; template <class _Val, class _Key, class _HashFcn, @@ -459,21 +481,31 @@ public: kwsys_stl::pair<iterator, bool> insert_unique_noresize(const value_type& __obj); iterator insert_equal_noresize(const value_type& __obj); -#if @KWSYS_NAMESPACE@_CXX_HAS_MEMBER_TEMPLATES +#if @KWSYS_NAMESPACE@_STL_HAS_ITERATOR_TRAITS +# define @KWSYS_NAMESPACE@_HASH_ITERATOR_CATEGORY(T,I) \ + typename kwsys_stl::iterator_traits< T >::iterator_category() +#elif @KWSYS_NAMESPACE@_STL_HAS_ITERATOR_CATEGORY +# define @KWSYS_NAMESPACE@_HASH_ITERATOR_CATEGORY(T,I) \ + kwsys_stl::iterator_category( I ) +#elif @KWSYS_NAMESPACE@_STL_HAS___ITERATOR_CATEGORY +# define @KWSYS_NAMESPACE@_HASH_ITERATOR_CATEGORY(T,I) \ + kwsys_stl::__iterator_category( I ) +#endif + +#if @KWSYS_NAMESPACE@_CXX_HAS_MEMBER_TEMPLATES && \ + defined(@KWSYS_NAMESPACE@_HASH_ITERATOR_CATEGORY) template <class _InputIterator> void insert_unique(_InputIterator __f, _InputIterator __l) { - typedef typename kwsys_stl::iterator_traits<_InputIterator>::iterator_category - iterator_category; - insert_unique(__f, __l, iterator_category()); + insert_unique(__f, __l, + @KWSYS_NAMESPACE@_HASH_ITERATOR_CATEGORY(_InputIterator, __f)); } template <class _InputIterator> void insert_equal(_InputIterator __f, _InputIterator __l) { - typedef typename kwsys_stl::iterator_traits<_InputIterator>::iterator_category - iterator_category; - insert_equal(__f, __l, iterator_category()); + insert_equal(__f, __l, + @KWSYS_NAMESPACE@_HASH_ITERATOR_CATEGORY(_InputIterator, __f)); } template <class _InputIterator> diff --git a/Source/kwsys/kwsysPlatformCxxTests.cxx b/Source/kwsys/kwsysPlatformCxxTests.cxx index 9edbfc0..a8b3d6f 100644 --- a/Source/kwsys/kwsysPlatformCxxTests.cxx +++ b/Source/kwsys/kwsysPlatformCxxTests.cxx @@ -122,6 +122,30 @@ int main() } #endif +#ifdef TEST_KWSYS_STL_HAS_ITERATOR_TRAITS +#include <iterator> +void f(kwsys_stl::iterator_traits<int*>::iterator_category const&) {} +int main() { return 0; } +#endif + +#ifdef TEST_KWSYS_STL_HAS_ITERATOR_CATEGORY +#include <iterator> +void f(int* x) { kwsys_stl::iterator_category(x); } +int main() { return 0; } +#endif + +#ifdef TEST_KWSYS_STL_HAS___ITERATOR_CATEGORY +#include <iterator> +void f(int* x) { kwsys_stl::__iterator_category(x); } +int main() { return 0; } +#endif + +#ifdef TEST_KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE +#include <memory> +void f(kwsys_stl::allocator const&) {} +int main() { return 0; } +#endif + #ifdef TEST_KWSYS_STL_HAS_ALLOCATOR_REBIND #include <memory> template <class T, class Alloc> |