From 5b18ae976eee68ada71df39650fda2c4570e1186 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Sun, 10 May 2020 23:08:14 +0300 Subject: [PATCH] Updated code to use distance and iterator_traits from std. --- test/counting_iterator_test.cpp | 6 +++--- test/iterator_traits_test.cpp | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/test/counting_iterator_test.cpp b/test/counting_iterator_test.cpp index 8f8da5f..0b1db7b 100644 --- a/test/counting_iterator_test.cpp +++ b/test/counting_iterator_test.cpp @@ -86,9 +86,9 @@ void category_test( std::random_access_iterator_tag) { typedef typename - boost::detail::iterator_traits::difference_type + std::iterator_traits::difference_type difference_type; - difference_type distance = boost::detail::distance(start, finish); + difference_type distance = std::distance(start, finish); // Pick a random position internal to the range difference_type offset = (unsigned)rand() % distance; @@ -110,7 +110,7 @@ void category_test( std::equal_range(start, finish, *internal)); CountingIterator x = xy.first, y = xy.second; - BOOST_TEST(boost::detail::distance(x, y) == 1); + BOOST_TEST(std::distance(x, y) == 1); // Show that values outside the range can't be found BOOST_TEST(!std::binary_search(start, boost::prior(finish), *finish)); diff --git a/test/iterator_traits_test.cpp b/test/iterator_traits_test.cpp index 1beb62d..f937f67 100644 --- a/test/iterator_traits_test.cpp +++ b/test/iterator_traits_test.cpp @@ -76,7 +76,7 @@ struct my_iterator2 // Used to prove that we're not overly confused by the existence of // std::iterator<> in the hierarchy under MSVC6 - we should find that -// boost::detail::iterator_traits::difference_type is int. +// std::iterator_traits::difference_type is int. struct my_iterator3 : my_iterator1 { typedef int difference_type; @@ -107,8 +107,8 @@ template struct non_portable_tests { - typedef typename boost::detail::iterator_traits::pointer test_pt; - typedef typename boost::detail::iterator_traits::reference test_rt; + typedef typename std::iterator_traits::pointer test_pt; + typedef typename std::iterator_traits::reference test_rt; typedef typename assert_same::type a1; typedef typename assert_same::type a2; }; @@ -117,8 +117,8 @@ template struct portable_tests { - typedef typename boost::detail::iterator_traits::difference_type test_dt; - typedef typename boost::detail::iterator_traits::iterator_category test_cat; + typedef typename std::iterator_traits::difference_type test_dt; + typedef typename std::iterator_traits::iterator_category test_cat; typedef typename assert_same::type a1; typedef typename assert_same::type a2; }; @@ -129,7 +129,7 @@ template { - typedef typename boost::detail::iterator_traits::value_type test_vt; + typedef typename std::iterator_traits::value_type test_vt; typedef typename assert_same::type a1; }; @@ -203,15 +203,15 @@ int main() for (int length = 3; length < 100; length += length / 3) { std::list l(length); - BOOST_TEST(boost::detail::distance(l.begin(), l.end()) == length); + BOOST_TEST(std::distance(l.begin(), l.end()) == length); std::vector v(length); - BOOST_TEST(boost::detail::distance(v.begin(), v.end()) == length); + BOOST_TEST(std::distance(v.begin(), v.end()) == length); - BOOST_TEST(boost::detail::distance(&ints[0], ints + length) == length); - BOOST_TEST(boost::detail::distance(my_iterator1(chars), my_iterator1(chars + length)) == length); - BOOST_TEST(boost::detail::distance(my_iterator2(chars), my_iterator2(chars + length)) == length); - BOOST_TEST(boost::detail::distance(my_iterator3(chars), my_iterator3(chars + length)) == length); + BOOST_TEST(std::distance(&ints[0], ints + length) == length); + BOOST_TEST(std::distance(my_iterator1(chars), my_iterator1(chars + length)) == length); + BOOST_TEST(std::distance(my_iterator2(chars), my_iterator2(chars + length)) == length); + BOOST_TEST(std::distance(my_iterator3(chars), my_iterator3(chars + length)) == length); } return boost::report_errors(); }