Replace boost::next with a simpler version

Less optimized, but hopefully it won't cause any warnings.
This commit is contained in:
Daniel James
2016-10-11 13:36:41 +01:00
parent a316d3fa46
commit 74abdd6973
5 changed files with 47 additions and 35 deletions
+6 -9
View File
@@ -13,10 +13,10 @@
#include "../helpers/test.hpp"
#include "../helpers/list.hpp"
#include "../helpers/invariants.hpp"
#include "../helpers/helpers.hpp"
#include <set>
#include <iostream>
#include <iterator>
#include <boost/next_prior.hpp>
#include "../objects/test.hpp"
#if BOOST_WORKAROUND(BOOST_MSVC, < 1400)
@@ -111,8 +111,8 @@ UNORDERED_AUTO_TEST(two_equivalent_item_tests)
{
collide_map x(init.begin(), init.end());
int value = boost::next(x.begin())->second;
x.erase(x.begin(), boost::next(x.begin()));
int value = test::next(x.begin())->second;
x.erase(x.begin(), test::next(x.begin()));
BOOST_TEST(x.count(1) == 1 && x.size() == 1 &&
x.begin()->first == 1 && x.begin()->second == value);
test::check_equivalent_keys(x);
@@ -121,7 +121,7 @@ UNORDERED_AUTO_TEST(two_equivalent_item_tests)
{
collide_map x(init.begin(), init.end());
int value = x.begin()->second;
x.erase(boost::next(x.begin()), x.end());
x.erase(test::next(x.begin()), x.end());
BOOST_TEST(x.count(1) == 1 && x.size() == 1 &&
x.begin()->first == 1 && x.begin()->second == value);
test::check_equivalent_keys(x);
@@ -143,13 +143,10 @@ bool compare(Range1 const& x, Range2 const& y)
template <class Container>
bool general_erase_range_test(Container& x, std::size_t start, std::size_t end)
{
typedef BOOST_DEDUCED_TYPENAME Container::difference_type difference_type;
difference_type start2 = start, end2 = end;
collide_list l(x.begin(), x.end());
l.erase(boost::next(l.begin(), start2), boost::next(l.begin(), end2));
x.erase(boost::next(x.begin(), start2), boost::next(x.begin(), end2));
l.erase(test::next(l.begin(), start), test::next(l.begin(), end));
x.erase(test::next(x.begin(), start), test::next(x.begin(), end));
test::check_equivalent_keys(x);
return compare(l, x);
+10 -16
View File
@@ -9,7 +9,6 @@
#include "../helpers/postfix.hpp"
#include "../helpers/test.hpp"
#include <boost/next_prior.hpp>
#include "../objects/test.hpp"
#include "../helpers/random_values.hpp"
#include "../helpers/tracker.hpp"
@@ -30,7 +29,6 @@ void erase_tests1(Container*, test::random_generator generator)
{
typedef BOOST_DEDUCED_TYPENAME Container::iterator iterator;
typedef BOOST_DEDUCED_TYPENAME Container::const_iterator c_iterator;
typedef BOOST_DEDUCED_TYPENAME Container::difference_type difference_type;
std::cerr<<"Erase by key.\n";
{
@@ -91,11 +89,10 @@ void erase_tests1(Container*, test::random_generator generator)
prev = pos = x.begin();
}
else {
prev = boost::next(x.begin(),
static_cast<difference_type>(index - 1));
pos = boost::next(prev);
prev = test::next(x.begin(), index - 1);
pos = test::next(prev);
}
next = boost::next(pos);
next = test::next(pos);
BOOST_DEDUCED_TYPENAME Container::key_type
key = test::get_key<Container>(*pos);
std::size_t count = x.count(key);
@@ -104,7 +101,7 @@ void erase_tests1(Container*, test::random_generator generator)
--size;
if(size > 0)
BOOST_TEST(index == 0 ? next == x.begin() :
next == boost::next(prev));
next == test::next(prev));
BOOST_TEST(x.count(key) == count - 1);
if (x.count(key) != count - 1) {
std::cerr << count << " => " << x.count(key) << std::endl;
@@ -163,10 +160,8 @@ void erase_tests1(Container*, test::random_generator generator)
std::size_t length = test::random_value(iterators.size() - start);
x.erase(iterators[start], iterators[start + length]);
iterators.erase(
boost::next(iterators.begin(),
static_cast<difference_type>(start)),
boost::next(iterators.begin(),
static_cast<difference_type>(start + length)));
test::next(iterators.begin(), start),
test::next(iterators.begin(), start + length));
BOOST_TEST(x.size() == iterators.size() - 1);
BOOST_DEDUCED_TYPENAME std::vector<c_iterator>::const_iterator
@@ -221,11 +216,10 @@ void erase_tests1(Container*, test::random_generator generator)
prev = pos = x.begin();
}
else {
prev = boost::next(x.begin(),
static_cast<difference_type>(index - 1));
pos = boost::next(prev);
prev = test::next(x.begin(), index - 1);
pos = test::next(prev);
}
next = boost::next(pos);
next = test::next(pos);
BOOST_DEDUCED_TYPENAME Container::key_type
key = test::get_key<Container>(*pos);
std::size_t count = x.count(key);
@@ -234,7 +228,7 @@ void erase_tests1(Container*, test::random_generator generator)
--size;
if(size > 0)
BOOST_TEST(index == 0 ? next == x.begin() :
next == boost::next(prev));
next == test::next(prev));
BOOST_TEST(x.count(key) == count - 1);
if (x.count(key) != count - 1) {
std::cerr << count << " => " << x.count(key) << std::endl;
+1 -2
View File
@@ -9,7 +9,6 @@
#include "../helpers/postfix.hpp"
#include "../helpers/test.hpp"
#include <boost/next_prior.hpp>
#include "../objects/test.hpp"
#include "../helpers/random_values.hpp"
#include "../helpers/tracker.hpp"
@@ -208,7 +207,7 @@ void insert_tests2(X*, test::random_generator generator)
old_bucket_count = x.bucket_count();
float b = x.max_load_factor();
x.insert(it, boost::next(it));
x.insert(it, test::next(it));
tracker.insert(*it);
tracker.compare_key(x, *it);