diff --git a/include/boost/intrusive/bstree.hpp b/include/boost/intrusive/bstree.hpp index 611de6c..5a0023a 100644 --- a/include/boost/intrusive/bstree.hpp +++ b/include/boost/intrusive/bstree.hpp @@ -85,8 +85,8 @@ struct bstbase3 typedef typename node_traits::const_node_ptr const_node_ptr; typedef tree_iterator iterator; typedef tree_iterator const_iterator; - typedef boost::intrusive::detail::reverse_iterator reverse_iterator; - typedef boost::intrusive::detail::reverse_iterator const_reverse_iterator; + typedef boost::intrusive::reverse_iterator reverse_iterator; + typedef boost::intrusive::reverse_iterator const_reverse_iterator; typedef BOOST_INTRUSIVE_IMPDEF(typename value_traits::pointer) pointer; typedef BOOST_INTRUSIVE_IMPDEF(typename value_traits::const_pointer) const_pointer; typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits::element_type) value_type; @@ -619,8 +619,8 @@ class bstree_impl typedef BOOST_INTRUSIVE_IMPDEF(value_compare) key_compare; typedef BOOST_INTRUSIVE_IMPDEF(iterator_type) iterator; typedef BOOST_INTRUSIVE_IMPDEF(const_iterator_type) const_iterator; - typedef BOOST_INTRUSIVE_IMPDEF(boost::intrusive::detail::reverse_iterator) reverse_iterator; - typedef BOOST_INTRUSIVE_IMPDEF(boost::intrusive::detail::reverse_iterator) const_reverse_iterator; + typedef BOOST_INTRUSIVE_IMPDEF(boost::intrusive::reverse_iterator) reverse_iterator; + typedef BOOST_INTRUSIVE_IMPDEF(boost::intrusive::reverse_iterator) const_reverse_iterator; typedef BOOST_INTRUSIVE_IMPDEF(typename value_traits::node_traits) node_traits; typedef BOOST_INTRUSIVE_IMPDEF(typename node_traits::node) node; typedef BOOST_INTRUSIVE_IMPDEF(typename node_traits::node_ptr) node_ptr; diff --git a/include/boost/intrusive/detail/iiterator.hpp b/include/boost/intrusive/detail/iiterator.hpp index 8378ead..f7e811c 100644 --- a/include/boost/intrusive/detail/iiterator.hpp +++ b/include/boost/intrusive/detail/iiterator.hpp @@ -17,67 +17,24 @@ # pragma once #endif +#include #include #include #include -#include - -#include - namespace boost { namespace intrusive { -template -struct iterator -{ - typedef Category iterator_category; - typedef T value_type; - typedef Distance difference_type; - typedef Pointer pointer; - typedef Reference reference; -}; - -template -struct iterator_traits -{ - typedef typename Iterator::difference_type difference_type; - typedef typename Iterator::value_type value_type; - typedef typename Iterator::pointer pointer; - typedef typename Iterator::reference reference; - typedef typename Iterator::iterator_category iterator_category; -}; - -template -struct iterator_traits -{ - typedef std::ptrdiff_t difference_type; - typedef T value_type; - typedef T* pointer; - typedef T& reference; - typedef std::random_access_iterator_tag iterator_category; -}; - -template -struct iterator_traits -{ - typedef std::ptrdiff_t difference_type; - typedef T value_type; - typedef const T* pointer; - typedef const T& reference; - typedef std::random_access_iterator_tag iterator_category; -}; - template struct value_traits_pointers { typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT (boost::intrusive::detail:: , ValueTraits, value_traits_ptr - , typename pointer_traits::template + , typename boost::intrusive::pointer_traits::template rebind_pointer::type) value_traits_ptr; - typedef typename pointer_traits::template + typedef typename boost::intrusive::pointer_traits::template rebind_pointer::type const_value_traits_ptr; }; @@ -154,73 +111,6 @@ struct iiterator_members NodePtr nodeptr_; }; -namespace detail { - -template inline -void advance_impl(InputIt& it, Distance n, const std::input_iterator_tag&) -{ - while(n--) - ++it; -} - -template inline -void advance_impl(InputIt& it, Distance n, std::forward_iterator_tag &) -{ - while(n--) - ++it; -} - -template inline -void advance_impl(InputIt& it, Distance n, std::bidirectional_iterator_tag &) -{ - for (; 0 < n; --n) - ++it; - for (; n < 0; ++n) - --it; -} - -template -inline void advance_impl(InputIt& it, Distance n, const std::random_access_iterator_tag &) -{ - it += n; -} - -} //namespace detail - -template -inline void iterator_advance(InputIt& it, Distance n) -{ // increment iterator by offset, arbitrary iterators - boost::intrusive::detail::advance_impl(it, n, boost::intrusive::iterator_traits::iterator_category()); -} - -namespace detail{ - -template -inline void distance_impl(InputIt first, InputIt last, Distance& off, const Category &) -{ - while(first != last){ - ++off; - ++first; - } -} - -template inline -void distance_impl(InputIt first, InputIt last, Distance& off, const std::random_access_iterator_tag&) -{ - off += last - first; -} - -} //namespace detail - -template inline -typename iterator_traits::difference_type iterator_distance(InputIt first, InputIt last) -{ - typename iterator_traits::difference_type off = 0; - boost::intrusive::detail::distance_impl(first, last, off, boost::intrusive::iterator_traits::iterator_category()); - return off; -} - - } //namespace intrusive } //namespace boost diff --git a/include/boost/intrusive/detail/iterator.hpp b/include/boost/intrusive/detail/iterator.hpp new file mode 100644 index 0000000..6a2bd2b --- /dev/null +++ b/include/boost/intrusive/detail/iterator.hpp @@ -0,0 +1,131 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-2014 +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_DETAIL_ITERATOR_HPP +#define BOOST_INTRUSIVE_DETAIL_ITERATOR_HPP + +#if defined(_MSC_VER) +# pragma once +#endif + +#include +#include + +namespace boost { +namespace intrusive { + +template +struct iterator +{ + typedef Category iterator_category; + typedef T value_type; + typedef Distance difference_type; + typedef Pointer pointer; + typedef Reference reference; +}; + +template +struct iterator_traits +{ + typedef typename Iterator::difference_type difference_type; + typedef typename Iterator::value_type value_type; + typedef typename Iterator::pointer pointer; + typedef typename Iterator::reference reference; + typedef typename Iterator::iterator_category iterator_category; +}; + +template +struct iterator_traits +{ + typedef std::ptrdiff_t difference_type; + typedef T value_type; + typedef T* pointer; + typedef T& reference; + typedef std::random_access_iterator_tag iterator_category; +}; + +template +struct iterator_traits +{ + typedef std::ptrdiff_t difference_type; + typedef T value_type; + typedef const T* pointer; + typedef const T& reference; + typedef std::random_access_iterator_tag iterator_category; +}; + +namespace detail { + +template inline +void advance_impl(InputIt& it, Distance n, const std::input_iterator_tag&) +{ + while(n--) + ++it; +} + +template inline +void advance_impl(InputIt& it, Distance n, std::forward_iterator_tag &) +{ + while(n--) + ++it; +} + +template inline +void advance_impl(InputIt& it, Distance n, std::bidirectional_iterator_tag &) +{ + for (; 0 < n; --n) + ++it; + for (; n < 0; ++n) + --it; +} + +template +inline void advance_impl(InputIt& it, Distance n, const std::random_access_iterator_tag &) +{ + it += n; +} + +template +inline void distance_impl(InputIt first, InputIt last, Distance& off, const Category &) +{ + while(first != last){ + ++off; + ++first; + } +} + +template inline +void distance_impl(InputIt first, InputIt last, Distance& off, const std::random_access_iterator_tag&) +{ + off += last - first; +} + +} //namespace detail + +template +inline void iterator_advance(InputIt& it, Distance n) +{ // increment iterator by offset, arbitrary iterators + boost::intrusive::detail::advance_impl(it, n, typename boost::intrusive::iterator_traits::iterator_category()); +} + +template inline +typename iterator_traits::difference_type iterator_distance(InputIt first, InputIt last) +{ + typename iterator_traits::difference_type off = 0; + boost::intrusive::detail::distance_impl(first, last, off, typename boost::intrusive::iterator_traits::iterator_category()); + return off; +} + +} //namespace intrusive +} //namespace boost + +#endif //BOOST_INTRUSIVE_DETAIL_ITERATOR_HPP diff --git a/include/boost/intrusive/detail/reverse_iterator.hpp b/include/boost/intrusive/detail/reverse_iterator.hpp index 9f443ab..9fb2314 100644 --- a/include/boost/intrusive/detail/reverse_iterator.hpp +++ b/include/boost/intrusive/detail/reverse_iterator.hpp @@ -10,19 +10,18 @@ // ///////////////////////////////////////////////////////////////////////////// -#ifndef BOOST_INTRUSIVE_DETAIL_ITERATOR_HPP -#define BOOST_INTRUSIVE_DETAIL_ITERATOR_HPP +#ifndef BOOST_INTRUSIVE_DETAIL_REVERSE_ITERATOR_HPP +#define BOOST_INTRUSIVE_DETAIL_REVERSE_ITERATOR_HPP #if defined(_MSC_VER) # pragma once #endif #include -#include +#include namespace boost { namespace intrusive { -namespace detail { template class reverse_iterator @@ -130,10 +129,9 @@ class reverse_iterator It m_current; // the wrapped iterator }; -} //namespace detail -} //namespace intrusive -} //namespace boost +} //namespace intrusive { +} //namespace boost { #include -#endif //BOOST_INTRUSIVE_DETAIL_ITERATOR_HPP +#endif //BOOST_INTRUSIVE_DETAIL_REVERSE_ITERATOR_HPP diff --git a/include/boost/intrusive/hashtable.hpp b/include/boost/intrusive/hashtable.hpp index 928844f..5cb2ae1 100644 --- a/include/boost/intrusive/hashtable.hpp +++ b/include/boost/intrusive/hashtable.hpp @@ -1660,7 +1660,7 @@ class hashtable_impl //! //! Effects: Equivalent to this->insert_equal(t) for each element in [b, e). //! - //! Complexity: Average case O(N), where N is std::distance(b, e). + //! Complexity: Average case O(N), where N is distance(b, e). //! Worst case O(N*this->size()). //! //! Throws: If the internal hasher or the equality functor throws. Basic guarantee. @@ -1706,7 +1706,7 @@ class hashtable_impl //! //! Effects: Equivalent to this->insert_unique(t) for each element in [b, e). //! - //! Complexity: Average case O(N), where N is std::distance(b, e). + //! Complexity: Average case O(N), where N is distance(b, e). //! Worst case O(N*this->size()). //! //! Throws: If the internal hasher or the equality functor throws. Basic guarantee. @@ -1819,7 +1819,7 @@ class hashtable_impl //! Effects: Erases the range pointed to by b end e. //! - //! Complexity: Average case O(std::distance(b, e)), + //! Complexity: Average case O(distance(b, e)), //! worst case O(this->size()). //! //! Throws: Nothing. @@ -1896,7 +1896,7 @@ class hashtable_impl //! Effects: Erases the range pointed to by b end e. //! Disposer::operator()(pointer) is called for the removed elements. //! - //! Complexity: Average case O(std::distance(b, e)), + //! Complexity: Average case O(distance(b, e)), //! worst case O(this->size()). //! //! Throws: Nothing. diff --git a/include/boost/intrusive/list.hpp b/include/boost/intrusive/list.hpp index 17d2faf..426c002 100644 --- a/include/boost/intrusive/list.hpp +++ b/include/boost/intrusive/list.hpp @@ -97,8 +97,8 @@ class list_impl typedef SizeType size_type; typedef list_iterator iterator; typedef list_iterator const_iterator; - typedef boost::intrusive::detail::reverse_iterator reverse_iterator; - typedef boost::intrusive::detail::reverse_iteratorconst_reverse_iterator; + typedef boost::intrusive::reverse_iterator reverse_iterator; + typedef boost::intrusive::reverse_iterator const_reverse_iterator; typedef typename value_traits::node_traits node_traits; typedef typename node_traits::node node; typedef typename node_traits::node_ptr node_ptr; @@ -187,7 +187,7 @@ class list_impl //! //! Effects: Constructs a list equal to the range [first,last). //! - //! Complexity: Linear in std::distance(b, e). No copy constructors are called. + //! Complexity: Linear in distance(b, e). No copy constructors are called. //! //! Throws: If value_traits::node_traits::node //! constructor throws (this does not happen with predefined Boost.Intrusive hooks). @@ -604,7 +604,7 @@ class list_impl } //! Requires: b and e must be valid iterators to elements in *this. - //! n must be std::distance(b, e). + //! n must be distance(b, e). //! //! Effects: Erases the element range pointed by b and e //! No destructors are called. @@ -915,12 +915,12 @@ class list_impl if(constant_time_size) this->splice(p, x, f, e, node_algorithms::distance(f.pointed_node(), e.pointed_node())); else - this->splice(p, x, f, e, 1);//distance is a dummy value + this->splice(p, x, f, e, 1);//intrusive::iterator_distance is a dummy value } //! Requires: p must be a valid iterator of *this. //! f and e must point to elements contained in list x. - //! n == std::distance(f, e) + //! n == distance(f, e) //! //! Effects: Transfers the range pointed by f and e from list x to this list, //! before the element pointed by p. No destructors or copy constructors are called. diff --git a/include/boost/intrusive/slist.hpp b/include/boost/intrusive/slist.hpp index 21e3e2e..47b5636 100644 --- a/include/boost/intrusive/slist.hpp +++ b/include/boost/intrusive/slist.hpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -314,7 +315,7 @@ class slist_impl //! //! Effects: Constructs a list equal to [b ,e). //! - //! Complexity: Linear in std::distance(b, e). No copy constructors are called. + //! Complexity: Linear in distance(b, e). No copy constructors are called. //! //! Throws: If value_traits::node_traits::node //! constructor throws (this does not happen with predefined Boost.Intrusive hooks). @@ -908,7 +909,7 @@ class slist_impl } //! Effects: Erases the range (before_f, l) from - //! the list. n must be std::distance(before_f, l) - 1. + //! the list. n must be distance(before_f, l) - 1. //! No destructors are called. //! //! Returns: the first element remaining beyond the removed elements, @@ -976,7 +977,7 @@ class slist_impl { return this->erase_after(this->previous(f), l); } //! Effects: Erases the range [f, l) from - //! the list. n must be std::distance(f, l). + //! the list. n must be distance(f, l). //! No destructors are called. //! //! Returns: the first element remaining beyond the removed elements, @@ -1266,7 +1267,7 @@ class slist_impl //! Requires: prev_pos must be a dereferenceable iterator in *this or be //! before_begin(), and before_f and before_l belong to x and //! ++before_f != x.end() && before_l != x.end() and - //! n == std::distance(before_f, before_l). + //! n == distance(before_f, before_l). //! //! Effects: Transfers the range (before_f, before_l] from list x to this //! list, after the element pointed by p. No destructors or copy constructors are called. @@ -1351,7 +1352,7 @@ class slist_impl //! Requires: pos must be a dereferenceable iterator in *this //! and f and l belong to x and f and l a valid range on x. - //! n == std::distance(f, l). + //! n == distance(f, l). //! //! Effects: Transfers the range [f, l) from list x to this //! list, before the element pointed by pos. @@ -1829,7 +1830,7 @@ class slist_impl //! Requires: prev_pos must be a dereferenceable iterator in *this or be //! before_begin(), and f and before_l belong to another slist. - //! n == std::distance(f, before_l) + 1. + //! n == distance(f, before_l) + 1. //! //! Effects: Transfers the range [f, before_l] to this //! list, after the element pointed by prev_pos. @@ -1848,7 +1849,7 @@ class slist_impl if(n){ BOOST_INTRUSIVE_INVARIANT_ASSERT(n > 0); BOOST_INTRUSIVE_INVARIANT_ASSERT - (size_type(std::distance + (size_type(boost::intrusive::iterator_distance ( iterator(f, this->priv_value_traits_ptr()) , iterator(before_l, this->priv_value_traits_ptr()))) +1 == n); diff --git a/include/boost/intrusive/treap_set.hpp b/include/boost/intrusive/treap_set.hpp index d735c8e..66b0531 100644 --- a/include/boost/intrusive/treap_set.hpp +++ b/include/boost/intrusive/treap_set.hpp @@ -101,7 +101,7 @@ class treap_set_impl //! [b, e). //! //! Complexity: Linear in N if [b, e) is already sorted using - //! comp and otherwise N * log N, where N is std::distance(last, first). + //! comp and otherwise N * log N, where N is distance(last, first). //! //! Throws: If value_traits::node_traits::node //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) @@ -602,7 +602,7 @@ class treap_multiset_impl //! [b, e). //! //! Complexity: Linear in N if [b, e) is already sorted using - //! comp and otherwise N * log N, where N is std::distance(last, first). + //! comp and otherwise N * log N, where N is distance(last, first). //! //! Throws: If value_traits::node_traits::node //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) diff --git a/include/boost/intrusive/unordered_set.hpp b/include/boost/intrusive/unordered_set.hpp index 7866fbd..27cd107 100644 --- a/include/boost/intrusive/unordered_set.hpp +++ b/include/boost/intrusive/unordered_set.hpp @@ -134,7 +134,7 @@ class unordered_set_impl //! Effects: Constructs an empty unordered_set and inserts elements from //! [b, e). //! - //! Complexity: If N is std::distance(b, e): Average case is O(N) + //! Complexity: If N is distance(b, e): Average case is O(N) //! (with a good hash function and with buckets_len >= N),worst case O(N2). //! //! Throws: If value_traits::node_traits::node @@ -325,7 +325,7 @@ class unordered_set_impl //! //! Effects: Equivalent to this->insert(t) for each element in [b, e). //! - //! Complexity: Average case O(N), where N is std::distance(b, e). + //! Complexity: Average case O(N), where N is distance(b, e). //! Worst case O(N*this->size()). //! //! Throws: If the internal hasher or the equality functor throws. Basic guarantee. @@ -413,7 +413,7 @@ class unordered_set_impl //! Effects: Erases the range pointed to by b end e. //! - //! Complexity: Average case O(std::distance(b, e)), + //! Complexity: Average case O(distance(b, e)), //! worst case O(this->size()). //! //! Throws: Nothing. @@ -485,7 +485,7 @@ class unordered_set_impl //! Effects: Erases the range pointed to by b end e. //! Disposer::operator()(pointer) is called for the removed elements. //! - //! Complexity: Average case O(std::distance(b, e)), + //! Complexity: Average case O(distance(b, e)), //! worst case O(this->size()). //! //! Throws: Nothing. @@ -1227,7 +1227,7 @@ class unordered_multiset_impl //! Effects: Constructs an empty unordered_multiset and inserts elements from //! [b, e). //! - //! Complexity: If N is std::distance(b, e): Average case is O(N) + //! Complexity: If N is distance(b, e): Average case is O(N) //! (with a good hash function and with buckets_len >= N),worst case O(N2). //! //! Throws: If value_traits::node_traits::node @@ -1442,7 +1442,7 @@ class unordered_multiset_impl //! Effects: Erases the range pointed to by b end e. //! - //! Complexity: Average case O(std::distance(b, e)), + //! Complexity: Average case O(distance(b, e)), //! worst case O(this->size()). //! //! Throws: Nothing. @@ -1521,7 +1521,7 @@ class unordered_multiset_impl //! Effects: Erases the range pointed to by b end e. //! Disposer::operator()(pointer) is called for the removed elements. //! - //! Complexity: Average case O(std::distance(b, e)), + //! Complexity: Average case O(distance(b, e)), //! worst case O(this->size()). //! //! Throws: Nothing. diff --git a/proj/vc7ide/_intrusivelib/_intrusivelib.vcproj b/proj/vc7ide/_intrusivelib/_intrusivelib.vcproj index 923cfce..d376bd7 100644 --- a/proj/vc7ide/_intrusivelib/_intrusivelib.vcproj +++ b/proj/vc7ide/_intrusivelib/_intrusivelib.vcproj @@ -292,6 +292,9 @@ + + diff --git a/test/common_functors.hpp b/test/common_functors.hpp index 7433d38..f3cbb29 100644 --- a/test/common_functors.hpp +++ b/test/common_functors.hpp @@ -13,7 +13,7 @@ #ifndef BOOST_INTRUSIVE_TEST_COMMON_FUNCTORS_HPP #define BOOST_INTRUSIVE_TEST_COMMON_FUNCTORS_HPP -#include +#include #include #include diff --git a/test/generic_multiset_test.hpp b/test/generic_multiset_test.hpp index 343dadd..f7d9fd1 100644 --- a/test/generic_multiset_test.hpp +++ b/test/generic_multiset_test.hpp @@ -15,6 +15,7 @@ #include "common_functors.hpp" #include #include +#include #include "test_macros.hpp" #include "test_container.hpp" #include "generic_assoc_test.hpp" @@ -226,7 +227,7 @@ void test_generic_multiset::test_find(value_cont_ BOOST_TEST (range.first->value_ == 2); BOOST_TEST (range.second->value_ == 3); - BOOST_TEST (std::distance (range.first, range.second) == 2); + BOOST_TEST (boost::intrusive::iterator_distance (range.first, range.second) == 2); (&cmp_val)->value_ = 7; BOOST_TEST (testset.find (cmp_val) == testset.end()); @@ -246,7 +247,7 @@ void test_generic_multiset::test_find(value_cont_ range = testset.bounded_range (cmp_val_lower, cmp_val_upper, true, true); BOOST_TEST (range.first->value_ == 1); BOOST_TEST (range.second->value_ == 3); - BOOST_TEST (std::distance (range.first, range.second) == 3); + BOOST_TEST (boost::intrusive::iterator_distance (range.first, range.second) == 3); } { (&cmp_val_lower)->value_ = 1; @@ -254,14 +255,14 @@ void test_generic_multiset::test_find(value_cont_ const_range = const_testset.bounded_range (cmp_val_lower, cmp_val_upper, true, false); BOOST_TEST (const_range.first->value_ == 1); BOOST_TEST (const_range.second->value_ == 2); - BOOST_TEST (std::distance (const_range.first, const_range.second) == 1); + BOOST_TEST (boost::intrusive::iterator_distance (const_range.first, const_range.second) == 1); (&cmp_val_lower)->value_ = 1; (&cmp_val_upper)->value_ = 3; range = testset.bounded_range (cmp_val_lower, cmp_val_upper, true, false); BOOST_TEST (range.first->value_ == 1); BOOST_TEST (range.second->value_ == 3); - BOOST_TEST (std::distance (range.first, range.second) == 3); + BOOST_TEST (boost::intrusive::iterator_distance (range.first, range.second) == 3); } { (&cmp_val_lower)->value_ = 1; @@ -269,7 +270,7 @@ void test_generic_multiset::test_find(value_cont_ const_range = const_testset.bounded_range (cmp_val_lower, cmp_val_upper, false, true); BOOST_TEST (const_range.first->value_ == 2); BOOST_TEST (const_range.second->value_ == 3); - BOOST_TEST (std::distance (const_range.first, const_range.second) == 2); + BOOST_TEST (boost::intrusive::iterator_distance (const_range.first, const_range.second) == 2); } { (&cmp_val_lower)->value_ = 1; @@ -277,7 +278,7 @@ void test_generic_multiset::test_find(value_cont_ range = testset.bounded_range (cmp_val_lower, cmp_val_upper, false, false); BOOST_TEST (range.first->value_ == 2); BOOST_TEST (range.second->value_ == 2); - BOOST_TEST (std::distance (range.first, range.second) == 0); + BOOST_TEST (boost::intrusive::iterator_distance (range.first, range.second) == 0); } { (&cmp_val_lower)->value_ = 5; @@ -285,7 +286,7 @@ void test_generic_multiset::test_find(value_cont_ const_range = const_testset.bounded_range (cmp_val_lower, cmp_val_upper, true, false); BOOST_TEST (const_range.first->value_ == 5); BOOST_TEST (const_range.second == const_testset.end()); - BOOST_TEST (std::distance (const_range.first, const_range.second) == 1); + BOOST_TEST (boost::intrusive::iterator_distance (const_range.first, const_range.second) == 1); } } } diff --git a/test/generic_set_test.hpp b/test/generic_set_test.hpp index ca137cf..8058149 100644 --- a/test/generic_set_test.hpp +++ b/test/generic_set_test.hpp @@ -15,6 +15,7 @@ #include "common_functors.hpp" #include #include +#include #include "test_macros.hpp" #include "test_container.hpp" #include "generic_assoc_test.hpp" @@ -292,7 +293,7 @@ void test_generic_set::test_find(value_cont_type& BOOST_TEST (range.first->value_ == 2); BOOST_TEST (range.second->value_ == 3); - BOOST_TEST (std::distance (range.first, range.second) == 1); + BOOST_TEST (boost::intrusive::iterator_distance (range.first, range.second) == 1); (&cmp_val)->value_ = 7; BOOST_TEST (testset.find (cmp_val) == testset.end()); @@ -314,7 +315,7 @@ void test_generic_set::test_find(value_cont_type& range = testset.bounded_range (cmp_val_lower, cmp_val_upper, true, true); BOOST_TEST (range.first->value_ == 1); BOOST_TEST (range.second->value_ == 3); - BOOST_TEST (std::distance (range.first, range.second) == 2); + BOOST_TEST (boost::intrusive::iterator_distance (range.first, range.second) == 2); } { (&cmp_val_lower)->value_ = 1; @@ -322,14 +323,14 @@ void test_generic_set::test_find(value_cont_type& const_range = const_testset.bounded_range (cmp_val_lower, cmp_val_upper, true, false); BOOST_TEST (const_range.first->value_ == 1); BOOST_TEST (const_range.second->value_ == 2); - BOOST_TEST (std::distance (const_range.first, const_range.second) == 1); + BOOST_TEST (boost::intrusive::iterator_distance (const_range.first, const_range.second) == 1); (&cmp_val_lower)->value_ = 1; (&cmp_val_upper)->value_ = 3; range = testset.bounded_range (cmp_val_lower, cmp_val_upper, true, false); BOOST_TEST (range.first->value_ == 1); BOOST_TEST (range.second->value_ == 3); - BOOST_TEST (std::distance (range.first, range.second) == 2); + BOOST_TEST (boost::intrusive::iterator_distance (range.first, range.second) == 2); } { (&cmp_val_lower)->value_ = 1; @@ -337,7 +338,7 @@ void test_generic_set::test_find(value_cont_type& const_range = const_testset.bounded_range (cmp_val_lower, cmp_val_upper, false, true); BOOST_TEST (const_range.first->value_ == 2); BOOST_TEST (const_range.second->value_ == 3); - BOOST_TEST (std::distance (const_range.first, const_range.second) == 1); + BOOST_TEST (boost::intrusive::iterator_distance (const_range.first, const_range.second) == 1); } { (&cmp_val_lower)->value_ = 1; @@ -345,7 +346,7 @@ void test_generic_set::test_find(value_cont_type& range = testset.bounded_range (cmp_val_lower, cmp_val_upper, false, false); BOOST_TEST (range.first->value_ == 2); BOOST_TEST (range.second->value_ == 2); - BOOST_TEST (std::distance (range.first, range.second) == 0); + BOOST_TEST (boost::intrusive::iterator_distance (range.first, range.second) == 0); } { (&cmp_val_lower)->value_ = 5; @@ -353,7 +354,7 @@ void test_generic_set::test_find(value_cont_type& const_range = const_testset.bounded_range (cmp_val_lower, cmp_val_upper, true, false); BOOST_TEST (const_range.first->value_ == 5); BOOST_TEST (const_range.second == const_testset.end()); - BOOST_TEST (std::distance (const_range.first, const_range.second) == 1); + BOOST_TEST (boost::intrusive::iterator_distance (const_range.first, const_range.second) == 1); } } } diff --git a/test/list_test.cpp b/test/list_test.cpp index 31f2b39..5476701 100644 --- a/test/list_test.cpp +++ b/test/list_test.cpp @@ -1,4 +1,3 @@ -/* ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. @@ -541,11 +540,3 @@ int main() return boost::report_errors(); } -*/ - -#include - -int main() -{ - return 0; -} \ No newline at end of file diff --git a/test/test_container.hpp b/test/test_container.hpp index 13f6f22..7872101 100644 --- a/test/test_container.hpp +++ b/test/test_container.hpp @@ -16,6 +16,7 @@ #include #include #include +#include #include namespace boost { @@ -386,14 +387,14 @@ void test_unordered_associative_container_invariants(Container & c, Data & d) di != de ; ++di ){ const_iterator i = c.find(*di); size_type nb = c.bucket(*i); - size_type bucket_elem = std::distance(c.begin(nb), c.end(nb)); + size_type bucket_elem = boost::intrusive::iterator_distance(c.begin(nb), c.end(nb)); BOOST_TEST( bucket_elem == c.bucket_size(nb) ); BOOST_TEST( &*c.local_iterator_to(*c.find(*di)) == &*i ); BOOST_TEST( &*c.local_iterator_to(*const_cast(c).find(*di)) == &*i ); BOOST_TEST( &*Container::s_local_iterator_to(*c.find(*di)) == &*i ); BOOST_TEST( &*Container::s_local_iterator_to(*const_cast(c).find(*di)) == &*i ); std::pair er = c.equal_range(*di); - size_type cnt = std::distance(er.first, er.second); + size_type cnt = boost::intrusive::iterator_distance(er.first, er.second); BOOST_TEST( cnt == c.count(*di)); if(cnt > 1){ const_iterator n = er.first; diff --git a/test/unordered_multiset_test.cpp b/test/unordered_multiset_test.cpp index 7144603..0d32635 100644 --- a/test/unordered_multiset_test.cpp +++ b/test/unordered_multiset_test.cpp @@ -12,6 +12,7 @@ ///////////////////////////////////////////////////////////////////////////// #include #include +#include #include "itestvalue.hpp" #include "smart_ptr.hpp" #include "common_functors.hpp" @@ -19,6 +20,7 @@ #include //std::sort std::find #include #include + #include "test_macros.hpp" #include "test_container.hpp" @@ -367,7 +369,7 @@ void test_unordered_multiset } //Erase the same values in both the intrusive and original vector - std::size_t erased_cnt = std::distance(it_beg_pos, it_end_pos); + std::size_t erased_cnt = boost::intrusive::iterator_distance(it_beg_pos, it_end_pos); //Erase values from the intrusive container testset.erase(it_beg_pos, it_end_pos); @@ -671,7 +673,7 @@ void test_unordered_multiset: BOOST_TEST (range.first->value_ == 2); BOOST_TEST (range.second->value_ == 3); - BOOST_TEST (std::distance (range.first, range.second) == 2); + BOOST_TEST (boost::intrusive::iterator_distance (range.first, range.second) == 2); cmp_val.value_ = 7; BOOST_TEST (testset.find (cmp_val) == testset.end()); diff --git a/test/unordered_set_test.cpp b/test/unordered_set_test.cpp index 271344f..96aa581 100644 --- a/test/unordered_set_test.cpp +++ b/test/unordered_set_test.cpp @@ -12,6 +12,7 @@ ///////////////////////////////////////////////////////////////////////////// #include #include +#include #include "itestvalue.hpp" #include "smart_ptr.hpp" #include "common_functors.hpp" @@ -180,7 +181,7 @@ void test_unordered_set:: unordered_set_type testset1(values.begin(), values.end(), bucket_traits( pointer_traits:: pointer_to(buckets[0]), BucketSize)); - BOOST_TEST (5 == std::distance(testset1.begin(), testset1.end())); + BOOST_TEST (5 == boost::intrusive::iterator_distance(testset1.begin(), testset1.end())); if(Incremental){ { int init_values [] = { 4, 5, 1, 2, 3 }; @@ -525,7 +526,7 @@ void test_unordered_set:: BOOST_TEST (range.first->value_ == 2); BOOST_TEST (range.second->value_ == 3); - BOOST_TEST (std::distance (range.first, range.second) == 1); + BOOST_TEST (boost::intrusive::iterator_distance (range.first, range.second) == 1); cmp_val.value_ = 7; BOOST_TEST (testset.find (cmp_val) == testset.end());