Boost logo

Boost-Commit :

From: daniel_james_at_[hidden]
Date: 2008-01-21 10:51:40


Author: danieljames
Date: 2008-01-21 10:51:40 EST (Mon, 21 Jan 2008)
New Revision: 42896
URL: http://svn.boost.org/trac/boost/changeset/42896

Log:
Use Boost config to tell when we have a std::distance function. Also, no need for a macro.
Text files modified:
   branches/unordered/trunk/boost/unordered/detail/hash_table.hpp | 12 +++---------
   branches/unordered/trunk/boost/unordered/detail/hash_table_impl.hpp | 6 +++---
   2 files changed, 6 insertions(+), 12 deletions(-)

Modified: branches/unordered/trunk/boost/unordered/detail/hash_table.hpp
==============================================================================
--- branches/unordered/trunk/boost/unordered/detail/hash_table.hpp (original)
+++ branches/unordered/trunk/boost/unordered/detail/hash_table.hpp 2008-01-21 10:51:40 EST (Mon, 21 Jan 2008)
@@ -110,20 +110,15 @@
             return std::pair<Dst1, Dst2>(Dst1(x.first), Dst2(x.second));
         }
 
- // Workaround for Apache stdcxx/Rogue Wave on compilers without partial specialization.
- // (Might not work on older versions?)
-
-#if BOOST_RWSTD_VER && _RWSTD_NO_CLASS_PARTIAL_SPEC
- #define BOOST_UNORDERED_DISTANCE ::boost::unordered_detail::distance
-
+#if !defined(BOOST_NO_STD_DISTANCE)
+ using ::std::distance;
+#else
         template <class ForwardIterator>
         inline std::size_t distance(ForwardIterator i, ForwardIterator j) {
             std::size_t x;
             std::distance(i, j, x);
             return x;
         }
-#else
- #define BOOST_UNORDERED_DISTANCE ::std::distance
 #endif
 
     }
@@ -196,7 +191,6 @@
     } // namespace boost::unordered_detail
 } // namespace boost
 
-#undef BOOST_UNORDERED_DISTANCE
 #undef BOOST_UNORDERED_BORLAND_BOOL
 #undef BOOST_UNORDERED_MSVC_RESET_PTR
 

Modified: branches/unordered/trunk/boost/unordered/detail/hash_table_impl.hpp
==============================================================================
--- branches/unordered/trunk/boost/unordered/detail/hash_table_impl.hpp (original)
+++ branches/unordered/trunk/boost/unordered/detail/hash_table_impl.hpp 2008-01-21 10:51:40 EST (Mon, 21 Jan 2008)
@@ -1045,7 +1045,7 @@
                     boost::forward_traversal_tag)
             {
                 // max load factor isn't set yet, but when it is, it'll be 1.0.
- return (std::max)(static_cast<size_type>(BOOST_UNORDERED_DISTANCE(i, j)) + 1, n);
+ return (std::max)(static_cast<size_type>(unordered_detail::distance(i, j)) + 1, n);
             }
 
             template <typename I>
@@ -1545,7 +1545,7 @@
             template <typename I>
             void insert_for_range(I i, I j, forward_traversal_tag)
             {
- size_type distance = BOOST_UNORDERED_DISTANCE(i, j);
+ size_type distance = unordered_detail::distance(i, j);
                 if(distance == 1) {
                     insert(*i);
                 }
@@ -1687,7 +1687,7 @@
             template <typename I>
             size_type insert_size(I i, I j, boost::forward_traversal_tag)
             {
- return BOOST_UNORDERED_DISTANCE(i, j);
+ return unordered_detail::distance(i, j);
             }
 
             template <typename I>


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