summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2005-04-13 19:39:03 (GMT)
committerBrad King <brad.king@kitware.com>2005-04-13 19:39:03 (GMT)
commitbe1084b5241725095a7e0591eaf593a4606204a1 (patch)
treecc9f9c5e94b5c22dd4f375d718e3eed75d82afd3 /Source
parent551b28d501058c3437b0c8d962e1662ccdbef392 (diff)
downloadCMake-be1084b5241725095a7e0591eaf593a4606204a1.zip
CMake-be1084b5241725095a7e0591eaf593a4606204a1.tar.gz
CMake-be1084b5241725095a7e0591eaf593a4606204a1.tar.bz2
COMP: Added KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT check for non-standard argument to stl allocator<>::max_size method. Needed for kwsys hashtable to compile on Sun CC.
Diffstat (limited to 'Source')
-rw-r--r--Source/kwsys/CMakeLists.txt2
-rw-r--r--Source/kwsys/Configure.hxx.in4
-rw-r--r--Source/kwsys/hashtable.hxx.in7
-rw-r--r--Source/kwsys/kwsysPlatformCxxTests.cxx13
4 files changed, 26 insertions, 0 deletions
diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt
index 7787933..7926da1 100644
--- a/Source/kwsys/CMakeLists.txt
+++ b/Source/kwsys/CMakeLists.txt
@@ -184,6 +184,8 @@ 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)
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 13d3a97..1ea8b37 100644
--- a/Source/kwsys/Configure.hxx.in
+++ b/Source/kwsys/Configure.hxx.in
@@ -96,6 +96,9 @@
/* Whether the stl allocator has rebind. */
#define @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_REBIND @KWSYS_STL_HAS_ALLOCATOR_REBIND@
+/* Whether the stl allocator has a size argument for max_size. */
+#define @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT @KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT@
+
/* Whether struct stat has the st_mtim member for high resolution times. */
#define @KWSYS_NAMESPACE@_STAT_HAS_ST_MTIM @KWSYS_STAT_HAS_ST_MTIM@
@@ -124,6 +127,7 @@
# define KWSYS_CXX_DEFINE_SPECIALIZATION @KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION
# define KWSYS_CXX_DECL_TYPENAME @KWSYS_NAMESPACE@_CXX_DECL_TYPENAME
# 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
#endif
#endif
diff --git a/Source/kwsys/hashtable.hxx.in b/Source/kwsys/hashtable.hxx.in
index a8cf6c7..033bcfd 100644
--- a/Source/kwsys/hashtable.hxx.in
+++ b/Source/kwsys/hashtable.hxx.in
@@ -119,11 +119,18 @@ public:
alloc_.deallocate(static_cast<alloc_pointer>(static_cast<void*>(p)), n*chunk());
}
}
+#if @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT
+ size_type max_size(size_type s) const throw()
+ {
+ return alloc_.max_size(s);
+ }
+#else
size_type max_size() const throw()
{
size_type n = alloc_.max_size() / chunk();
return n>0? n:1;
}
+#endif
void construct(pointer p, const value_type& val) { new (p) value_type(val); }
void destroy(pointer p) { (void)p; p->~value_type(); }
private:
diff --git a/Source/kwsys/kwsysPlatformCxxTests.cxx b/Source/kwsys/kwsysPlatformCxxTests.cxx
index 5c1288e..74e83bd 100644
--- a/Source/kwsys/kwsysPlatformCxxTests.cxx
+++ b/Source/kwsys/kwsysPlatformCxxTests.cxx
@@ -122,6 +122,19 @@ int main()
}
#endif
+#ifdef TEST_KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT
+#include <memory>
+void f(kwsys_stl::allocator<char> const& a)
+{
+ a.max_size(sizeof(int));
+};
+int main()
+{
+ f(kwsys_stl::allocator<char>());
+ return 0;
+}
+#endif
+
#ifdef TEST_KWSYS_STAT_HAS_ST_MTIM
#include <sys/types.h>
#include <sys/stat.h>