Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r49031 - in trunk: boost/pool libs/pool/test
From: chris.newbold_at_[hidden]
Date: 2008-09-29 16:25:28


Author: cnewbold
Date: 2008-09-29 16:25:28 EDT (Mon, 29 Sep 2008)
New Revision: 49031
URL: http://svn.boost.org/trac/boost/changeset/49031

Log:
Address ticket #1996: "void" template specialization for pool allocators.

Text files modified:
   trunk/boost/pool/pool_alloc.hpp | 30 ++++++++++++++++++++++++++++++
   trunk/libs/pool/test/test_pool_alloc.cpp | 17 +++++++++++++++++
   2 files changed, 47 insertions(+), 0 deletions(-)

Modified: trunk/boost/pool/pool_alloc.hpp
==============================================================================
--- trunk/boost/pool/pool_alloc.hpp (original)
+++ trunk/boost/pool/pool_alloc.hpp 2008-09-29 16:25:28 EDT (Mon, 29 Sep 2008)
@@ -127,6 +127,21 @@
     }
 };
 
+template<
+ typename UserAllocator,
+ typename Mutex,
+ unsigned NextSize>
+class pool_allocator<void, UserAllocator, Mutex, NextSize>
+{
+public:
+ typedef void* pointer;
+ typedef const void* const_pointer;
+ typedef void value_type;
+ template <class U> struct rebind {
+ typedef pool_allocator<U, UserAllocator, Mutex, NextSize> other;
+ };
+};
+
 struct fast_pool_allocator_tag { };
 
 template <typename T,
@@ -247,6 +262,21 @@
     }
 };
 
+template<
+ typename UserAllocator,
+ typename Mutex,
+ unsigned NextSize>
+class fast_pool_allocator<void, UserAllocator, Mutex, NextSize>
+{
+public:
+ typedef void* pointer;
+ typedef const void* const_pointer;
+ typedef void value_type;
+ template <class U> struct rebind {
+ typedef fast_pool_allocator<U, UserAllocator, Mutex, NextSize> other;
+ };
+};
+
 } // namespace boost
 
 #endif

Modified: trunk/libs/pool/test/test_pool_alloc.cpp
==============================================================================
--- trunk/libs/pool/test/test_pool_alloc.cpp (original)
+++ trunk/libs/pool/test/test_pool_alloc.cpp 2008-09-29 16:25:28 EDT (Mon, 29 Sep 2008)
@@ -304,11 +304,28 @@
     std::cout << "Memory error" << std::endl;
 }
 
+void test_void()
+{
+#ifdef VERBOSE
+ std::cout << "Testing void specialization. . ." << std::endl;
+#endif
+
+ typedef boost::pool_allocator<void> void_allocator;
+ typedef boost::fast_pool_allocator<void> fast_void_allocator;
+
+ typedef void_allocator::rebind<int>::other int_allocator;
+ typedef fast_void_allocator::rebind<int>::other fast_int_allocator;
+
+ std::vector<int, int_allocator> v1;
+ std::vector<int, fast_int_allocator> v2;
+}
+
 int test_main(int, char * [])
 {
   test();
   test_alloc();
   test_mem_usage();
+ test_void();
 
 #ifdef VERBOSE
   std::cout << "main() exiting. . ." << std::endl;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk