Use std::advance in test::next, and use it instead of boost::next

Mainly to avoid warnings from boost::next
This commit is contained in:
Daniel James 2017-12-01 08:11:36 +00:00
parent ecd5b239a4
commit 9bb861accc
3 changed files with 14 additions and 14 deletions

View File

@ -6,6 +6,8 @@
#if !defined(BOOST_UNORDERED_TEST_HELPERS_HEADER) #if !defined(BOOST_UNORDERED_TEST_HELPERS_HEADER)
#define BOOST_UNORDERED_TEST_HELPERS_HEADER #define BOOST_UNORDERED_TEST_HELPERS_HEADER
#include <iterator>
namespace test { namespace test {
template <class Container> struct get_key_impl template <class Container> struct get_key_impl
{ {
@ -36,16 +38,16 @@ namespace test {
// test::next // test::next
// //
// Increments an iterator by 1 or a given value. // Increments an iterator by 1 or a given value.
// Like boost::next, but simpler and slower. // Like boost::next, but simpler.
// Mainly because boost::next uses an MPL file
// which causes warnings.
template <typename Iterator> Iterator next(Iterator it) { return ++it; } template <typename Iterator> Iterator next(Iterator it) { return ++it; }
template <typename Iterator, typename IntType> template <typename Iterator, typename IntType>
Iterator next(Iterator it, IntType x) Iterator next(Iterator it, IntType x)
{ {
for (; x > 0; --x) { std::advance(it, x);
++it;
}
return it; return it;
} }
} }

View File

@ -17,7 +17,6 @@
#include "../helpers/test.hpp" #include "../helpers/test.hpp"
#include "../helpers/tracker.hpp" #include "../helpers/tracker.hpp"
#include "../objects/test.hpp" #include "../objects/test.hpp"
#include <boost/next_prior.hpp>
namespace extract_tests { namespace extract_tests {
@ -94,10 +93,10 @@ namespace extract_tests {
if (index == 0) { if (index == 0) {
prev = pos = x.begin(); prev = pos = x.begin();
} else { } else {
prev = boost::next(x.begin(), index - 1); prev = test::next(x.begin(), index - 1);
pos = boost::next(prev); pos = test::next(prev);
} }
next = boost::next(pos); next = test::next(pos);
BOOST_DEDUCED_TYPENAME Container::key_type key = BOOST_DEDUCED_TYPENAME Container::key_type key =
test::get_key<Container>(*pos); test::get_key<Container>(*pos);
std::size_t count = x.count(key); std::size_t count = x.count(key);
@ -106,7 +105,7 @@ namespace extract_tests {
--size; --size;
if (size > 0) if (size > 0)
BOOST_TEST( BOOST_TEST(
index == 0 ? next == x.begin() : next == boost::next(prev)); index == 0 ? next == x.begin() : next == test::next(prev));
BOOST_TEST(x.count(key) == count - 1); BOOST_TEST(x.count(key) == count - 1);
BOOST_TEST(x.size() == size); BOOST_TEST(x.size() == size);
if (++iterations % 20 == 0) if (++iterations % 20 == 0)

View File

@ -15,7 +15,6 @@
#include "../helpers/test.hpp" #include "../helpers/test.hpp"
#include "../helpers/tracker.hpp" #include "../helpers/tracker.hpp"
#include "../objects/test.hpp" #include "../objects/test.hpp"
#include <boost/next_prior.hpp>
namespace merge_tests { namespace merge_tests {
@ -174,8 +173,8 @@ namespace merge_tests {
test::random_values<X1> v1(1000, generator); test::random_values<X1> v1(1000, generator);
test::random_values<X2> v2(1000, generator); test::random_values<X2> v2(1000, generator);
v1.insert(v2.begin(), boost::next(v2.begin(), 100)); v1.insert(v2.begin(), test::next(v2.begin(), 100));
v2.insert(v1.begin(), boost::next(v1.begin(), 100)); v2.insert(v1.begin(), test::next(v1.begin(), 100));
X1 x1(v1.begin(), v1.end(), 0, test::hash(hash_equal1), X1 x1(v1.begin(), v1.end(), 0, test::hash(hash_equal1),
test::equal_to(hash_equal1)); test::equal_to(hash_equal1));
@ -207,8 +206,8 @@ namespace merge_tests {
test::random_values<X1> v1(1000, generator); test::random_values<X1> v1(1000, generator);
test::random_values<X2> v2(1000, generator); test::random_values<X2> v2(1000, generator);
v1.insert(v2.begin(), boost::next(v2.begin(), 100)); v1.insert(v2.begin(), test::next(v2.begin(), 100));
v2.insert(v1.begin(), boost::next(v1.begin(), 100)); v2.insert(v1.begin(), test::next(v1.begin(), 100));
X1 x1(v1.begin(), v1.end(), 0, test::hash(hash_equal1), X1 x1(v1.begin(), v1.end(), 0, test::hash(hash_equal1),
test::equal_to(hash_equal1)); test::equal_to(hash_equal1));