Unordered: Use container's allocator_traits for old Visual C++.

[SVN r77017]
This commit is contained in:
Daniel James
2012-02-14 23:55:09 +00:00
parent 08230efb44
commit 8a1a475c58
3 changed files with 23 additions and 5 deletions

View File

@ -31,14 +31,20 @@
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))
# define BOOST_UNORDERED_USE_ALLOCATOR_TRAITS 1
# endif
#
# if defined(BOOST_MSVC) && BOOST_MSVC < 1400
# define BOOST_UNORDERED_USE_ALLOCATOR_TRAITS 2
# endif
#endif
#if !defined(BOOST_UNORDERED_USE_ALLOCATOR_TRAITS)
# define BOOST_UNORDERED_USE_ALLOCATOR_TRAITS 0
#endif
#if BOOST_UNORDERED_USE_ALLOCATOR_TRAITS
#if BOOST_UNORDERED_USE_ALLOCATOR_TRAITS == 1
# include <memory>
#elif BOOST_UNORDERED_USE_ALLOCATOR_TRAITS == 2
# include <boost/container/allocator/allocator_traits.hpp>
#endif
#if !defined(BOOST_NO_0X_HDR_TYPE_TRAITS)
@ -201,7 +207,7 @@ namespace boost { namespace unordered { namespace detail {
// Uses the standard versions if available.
// (although untested as I don't have access to a standard version yet)
#if BOOST_UNORDERED_USE_ALLOCATOR_TRAITS
#if BOOST_UNORDERED_USE_ALLOCATOR_TRAITS == 1
template <typename Alloc>
struct allocator_traits : std::allocator_traits<Alloc> {};
@ -213,6 +219,18 @@ namespace boost { namespace unordered { namespace detail {
template rebind_alloc<T> type;
};
#elif BOOST_UNORDERED_USE_ALLOCATOR_TRAITS == 2
template <typename Alloc>
struct allocator_traits :
boost::container::allocator_traits<Alloc> {};
template <typename Alloc, typename T>
struct rebind_wrap :
boost::container::allocator_traits<Alloc>::
template portable_rebind_alloc<T>
{};
#else
// TODO: Does this match std::allocator_traits<Alloc>::rebind_alloc<T>?

View File

@ -90,7 +90,7 @@ void test_empty_allocator()
{
typedef empty_allocator<int> allocator;
typedef boost::unordered::detail::allocator_traits<allocator> traits;
#if BOOST_UNORDERED_USE_ALLOCATOR_TRAITS
#if BOOST_UNORDERED_USE_ALLOCATOR_TRAITS == 1
BOOST_MPL_ASSERT((boost::is_same<traits::size_type,
std::make_unsigned<std::ptrdiff_t>::type>));
#else
@ -128,7 +128,7 @@ void test_allocator1()
{
typedef allocator1<int> allocator;
typedef boost::unordered::detail::allocator_traits<allocator> traits;
#if BOOST_UNORDERED_USE_ALLOCATOR_TRAITS
#if BOOST_UNORDERED_USE_ALLOCATOR_TRAITS == 1
BOOST_MPL_ASSERT((boost::is_same<typename traits::size_type,
std::make_unsigned<std::ptrdiff_t>::type>));
#else

View File

@ -52,7 +52,7 @@ void test_simple_allocator()
BOOST_MPL_ASSERT((boost::is_same<typename traits::difference_type, std::ptrdiff_t>));
#if BOOST_UNORDERED_USE_ALLOCATOR_TRAITS
#if BOOST_UNORDERED_USE_ALLOCATOR_TRAITS == 1
BOOST_MPL_ASSERT((boost::is_same<typename traits::size_type,
std::make_unsigned<std::ptrdiff_t>::type>));
#else