Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77017 - in trunk: boost/unordered/detail libs/unordered/test/unordered
From: dnljms_at_[hidden]
Date: 2012-02-14 18:55:10


Author: danieljames
Date: 2012-02-14 18:55:09 EST (Tue, 14 Feb 2012)
New Revision: 77017
URL: http://svn.boost.org/trac/boost/changeset/77017

Log:
Unordered: Use container's allocator_traits for old Visual C++.
Text files modified:
   trunk/boost/unordered/detail/allocator_helpers.hpp | 22 ++++++++++++++++++++--
   trunk/libs/unordered/test/unordered/allocator_traits.cpp | 4 ++--
   trunk/libs/unordered/test/unordered/minimal_allocator.cpp | 2 +-
   3 files changed, 23 insertions(+), 5 deletions(-)

Modified: trunk/boost/unordered/detail/allocator_helpers.hpp
==============================================================================
--- trunk/boost/unordered/detail/allocator_helpers.hpp (original)
+++ trunk/boost/unordered/detail/allocator_helpers.hpp 2012-02-14 18:55:09 EST (Tue, 14 Feb 2012)
@@ -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 @@
     // 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 @@
             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>?

Modified: trunk/libs/unordered/test/unordered/allocator_traits.cpp
==============================================================================
--- trunk/libs/unordered/test/unordered/allocator_traits.cpp (original)
+++ trunk/libs/unordered/test/unordered/allocator_traits.cpp 2012-02-14 18:55:09 EST (Tue, 14 Feb 2012)
@@ -90,7 +90,7 @@
 {
     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 @@
 {
     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

Modified: trunk/libs/unordered/test/unordered/minimal_allocator.cpp
==============================================================================
--- trunk/libs/unordered/test/unordered/minimal_allocator.cpp (original)
+++ trunk/libs/unordered/test/unordered/minimal_allocator.cpp 2012-02-14 18:55:09 EST (Tue, 14 Feb 2012)
@@ -52,7 +52,7 @@
 
     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


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