Boost logo

Boost-Commit :

From: daniel_james_at_[hidden]
Date: 2008-01-15 06:33:03


Author: danieljames
Date: 2008-01-15 06:33:02 EST (Tue, 15 Jan 2008)
New Revision: 42790
URL: http://svn.boost.org/trac/boost/changeset/42790

Log:
Reuse the unordered allocator rebind stuff in the unit test helpers.
Text files modified:
   branches/unordered/trunk/libs/unordered/test/objects/exception.hpp | 8 +-------
   branches/unordered/trunk/libs/unordered/test/objects/memory.hpp | 14 ++++++++------
   branches/unordered/trunk/libs/unordered/test/objects/test.hpp | 2 +-
   3 files changed, 10 insertions(+), 14 deletions(-)

Modified: branches/unordered/trunk/libs/unordered/test/objects/exception.hpp
==============================================================================
--- branches/unordered/trunk/libs/unordered/test/objects/exception.hpp (original)
+++ branches/unordered/trunk/libs/unordered/test/objects/exception.hpp 2008-01-15 06:33:02 EST (Tue, 15 Jan 2008)
@@ -21,15 +21,9 @@
 {
     namespace detail
     {
- struct malloc_allocator_holder {
- template <class T> struct apply {
- typedef test::malloc_allocator<T> type;
- };
- };
-
         namespace
         {
- test::detail::memory_tracker<malloc_allocator_holder> tracker;
+ test::detail::memory_tracker<test::malloc_allocator<int> > tracker;
         }
     }
 

Modified: branches/unordered/trunk/libs/unordered/test/objects/memory.hpp
==============================================================================
--- branches/unordered/trunk/libs/unordered/test/objects/memory.hpp (original)
+++ branches/unordered/trunk/libs/unordered/test/objects/memory.hpp 2008-01-15 06:33:02 EST (Tue, 15 Jan 2008)
@@ -10,6 +10,7 @@
 #include <map>
 #include <boost/mpl/apply.hpp>
 #include <boost/assert.hpp>
+#include <boost/unordered/detail/allocator.hpp>
 #include "../helpers/test.hpp"
 
 namespace test
@@ -56,14 +57,15 @@
             }
         };
 
- struct default_allocator_holder { template <class T> struct apply {
- typedef std::allocator<T> type; }; };
-
- template <class AllocatorHolder = default_allocator_holder>
+ template <class Alloc = std::allocator<int> >
         struct memory_tracker {
+ typedef BOOST_DEDUCED_TYPENAME
+ boost::unordered_detail::rebind_wrap<Alloc,
+ std::pair<memory_area const, memory_track> >::type
+ allocator;
+
             typedef std::map<memory_area, memory_track, memory_area_compare,
- BOOST_DEDUCED_TYPENAME boost::mpl::apply1<AllocatorHolder, std::pair<memory_area const, memory_track> >::type
- > allocated_memory_type;
+ allocator> allocated_memory_type;
 
             allocated_memory_type allocated_memory;
             unsigned int count_allocators;

Modified: branches/unordered/trunk/libs/unordered/test/objects/test.hpp
==============================================================================
--- branches/unordered/trunk/libs/unordered/test/objects/test.hpp (original)
+++ branches/unordered/trunk/libs/unordered/test/objects/test.hpp 2008-01-15 06:33:02 EST (Tue, 15 Jan 2008)
@@ -205,7 +205,7 @@
     namespace detail
     {
         namespace {
- test::detail::memory_tracker<test::detail::default_allocator_holder> tracker;
+ test::detail::memory_tracker<std::allocator<int> > tracker;
         }
     }
 


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