Merge in some changes to the unordered tests.

[SVN r42856]
This commit is contained in:
Daniel James
2008-01-18 19:35:55 +00:00
parent 00c2c3bc4c
commit 01df4d9dc2
4 changed files with 28 additions and 18 deletions

View File

@ -44,9 +44,9 @@ namespace test
pointer allocate(size_type n, const_pointer u) { return allocate(n); }
#if defined(__IBMCPP__)
// Workaround for IBM Visual Age which seems to use a void pointer
// for the second argument.
#if defined(__IBMCPP__) || BOOST_WORKAROUND(BOOST_RWSTD_VER, < 0x04020000)
// Workaround for IBM Visual Age and Rogue Wave (or maybe just Apache stdcxx?)
// which seem to use a void pointer for the second argument.
pointer allocate(size_type n, void const* u) { return allocate(n); }
#endif

View File

@ -21,15 +21,9 @@ namespace exception
{
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;
}
}

View File

@ -10,6 +10,8 @@
#include <map>
#include <boost/mpl/apply.hpp>
#include <boost/assert.hpp>
#include <boost/unordered/detail/allocator.hpp>
#include <boost/mpl/aux_/config/eti.hpp>
#include "../helpers/test.hpp"
namespace test
@ -56,14 +58,28 @@ namespace test
}
};
struct default_allocator_holder { template <class T> struct apply {
typedef std::allocator<T> type; }; };
template <class AllocatorHolder = default_allocator_holder>
struct memory_tracker {
template <class Alloc>
struct allocator_memory_type_gen {
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;
Alloc> type;
};
#if defined(BOOST_MPL_CFG_MSVC_ETI_BUG)
template <>
struct allocator_memory_type_gen<int> {
typedef std::map<memory_area, memory_track, memory_area_compare> type;
};
#endif
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_type;
typedef BOOST_DEDUCED_TYPENAME allocator_memory_type_gen<allocator_type>::type
allocated_memory_type;
allocated_memory_type allocated_memory;
unsigned int count_allocators;

View File

@ -205,7 +205,7 @@ namespace test
namespace detail
{
namespace {
test::detail::memory_tracker<test::detail::default_allocator_holder> tracker;
test::detail::memory_tracker<std::allocator<int> > tracker;
}
}