Boost logo

Boost-Commit :

From: daniel_james_at_[hidden]
Date: 2008-01-21 08:03:16


Author: danieljames
Date: 2008-01-21 08:03:16 EST (Mon, 21 Jan 2008)
New Revision: 42892
URL: http://svn.boost.org/trac/boost/changeset/42892

Log:
On some compilers the Rogue Wave/Apache stdcxx library doesn't have the normal std::distance, but instead has a variant that takes the result as the third parameter so it doesn't have to work out the type from the iterator.
Text files modified:
   branches/unordered/trunk/boost/unordered/detail/hash_table.hpp | 18 ++++++++++++++++++
   branches/unordered/trunk/boost/unordered/detail/hash_table_impl.hpp | 6 +++---
   2 files changed, 21 insertions(+), 3 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 08:03:16 EST (Mon, 21 Jan 2008)
@@ -109,6 +109,23 @@
         {
             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
+
+ template <class ForwardIterator>
+ inline std::size_type distance(ForwardIterator i, ForwardIterator j) {
+ std::size_type x;
+ std::distance(i, j, x);
+ return x;
+ }
+#else
+ #define BOOST_UNORDERED_DISTANCE ::std::distance
+#endif
+
     }
 }
 
@@ -179,6 +196,7 @@
     } // 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 08:03:16 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>(std::distance(i, j)) + 1, n);
+ return (std::max)(static_cast<size_type>(BOOST_UNORDERED_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 = std::distance(i, j);
+ size_type distance = BOOST_UNORDERED_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 std::distance(i, j);
+ return BOOST_UNORDERED_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