Commit b2c5192a authored by Brad King's avatar Brad King
Browse files

COMP: Added KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT check for non-standard...

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.
parent 9195d87f
......@@ -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)
......
......@@ -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
......@@ -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:
......
......@@ -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>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment