forked from boostorg/container
Refactored uses of <iterator> and <algorithm> to avoid dependencies where possible.
This commit is contained in:
@@ -14,11 +14,11 @@
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <boost/container/detail/pair.hpp>
|
||||
#include <boost/container/detail/mpl.hpp>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <boost/move/unique_ptr.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <boost/container/detail/iterator.hpp>
|
||||
|
||||
namespace boost{
|
||||
namespace container {
|
||||
namespace test{
|
||||
@@ -68,7 +68,7 @@ bool CheckEqualContainers(const MyBoostCont &boostcont, const MyStdCont &stdcont
|
||||
|
||||
typename MyBoostCont::const_iterator itboost(boostcont.begin()), itboostend(boostcont.end());
|
||||
typename MyStdCont::const_iterator itstd(stdcont.begin());
|
||||
typename MyStdCont::size_type dist = (typename MyStdCont::size_type)std::distance(itboost, itboostend);
|
||||
typename MyStdCont::size_type dist = (typename MyStdCont::size_type)boost::container::iterator_distance(itboost, itboostend);
|
||||
if(dist != boostcont.size()){
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -14,8 +14,9 @@
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <vector>
|
||||
#include <typeinfo>
|
||||
#include <iostream>
|
||||
#include "expand_bwd_test_allocator.hpp"
|
||||
#include <algorithm>
|
||||
#include <boost/container/detail/algorithm.hpp> //equal()
|
||||
#include "movable_int.hpp"
|
||||
#include <boost/type_traits/remove_volatile.hpp>
|
||||
#include <boost/move/make_unique.hpp>
|
||||
@@ -28,7 +29,7 @@ bool CheckEqualVector(const Vector1 &vector1, const Vector2 &vector2)
|
||||
{
|
||||
if(vector1.size() != vector2.size())
|
||||
return false;
|
||||
return std::equal(vector1.begin(), vector1.end(), vector2.begin());
|
||||
return boost::container::algo_equal(vector1.begin(), vector1.end(), vector2.begin());
|
||||
}
|
||||
|
||||
template<class Vector>
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <boost/container/allocator.hpp>
|
||||
#include <boost/container/node_allocator.hpp>
|
||||
#include <boost/container/adaptive_pool.hpp>
|
||||
#include <boost/container/detail/flat_tree.hpp>
|
||||
|
||||
#include "print_container.hpp"
|
||||
#include "dummy_test_allocator.hpp"
|
||||
@@ -21,8 +22,10 @@
|
||||
#include "propagate_allocator_test.hpp"
|
||||
#include "container_common_tests.hpp"
|
||||
#include "emplace_test.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <boost/container/detail/flat_tree.hpp>
|
||||
#include <map>
|
||||
|
||||
|
||||
using namespace boost::container;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#ifndef BOOST_CONTAINER_TEST_FORWARD_TO_INPUT_ITERATOR_HPP
|
||||
#define BOOST_CONTAINER_TEST_FORWARD_TO_INPUT_ITERATOR_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <boost/container/detail/iterator.hpp>
|
||||
|
||||
namespace boost{
|
||||
namespace container {
|
||||
@@ -19,11 +19,11 @@ namespace test{
|
||||
|
||||
template<class FwdIterator>
|
||||
class input_iterator_wrapper
|
||||
: public std::iterator< std::input_iterator_tag
|
||||
, typename std::iterator_traits<FwdIterator>::value_type
|
||||
, typename std::iterator_traits<FwdIterator>::difference_type
|
||||
, typename std::iterator_traits<FwdIterator>::pointer
|
||||
, typename std::iterator_traits<FwdIterator>::reference
|
||||
: public boost::container::iterator< std::input_iterator_tag
|
||||
, typename boost::container::iterator_traits<FwdIterator>::value_type
|
||||
, typename boost::container::iterator_traits<FwdIterator>::difference_type
|
||||
, typename boost::container::iterator_traits<FwdIterator>::pointer
|
||||
, typename boost::container::iterator_traits<FwdIterator>::reference
|
||||
>
|
||||
{
|
||||
FwdIterator m_it;
|
||||
@@ -46,10 +46,10 @@ class input_iterator_wrapper
|
||||
//Default destructor...
|
||||
//~input_iterator_wrapper();
|
||||
|
||||
typename std::iterator_traits<FwdIterator>::reference operator*() const
|
||||
typename boost::container::iterator_traits<FwdIterator>::reference operator*() const
|
||||
{ return *m_it; }
|
||||
|
||||
typename std::iterator_traits<FwdIterator>::pointer operator->() const
|
||||
typename boost::container::iterator_traits<FwdIterator>::pointer operator->() const
|
||||
{ return m_it.operator->(); }
|
||||
|
||||
input_iterator_wrapper& operator++()
|
||||
|
||||
+2
-2
@@ -53,9 +53,9 @@ template class boost::container::list
|
||||
|
||||
namespace container_detail {
|
||||
|
||||
template class iterator
|
||||
template class iterator_from_iiterator
|
||||
<intrusive_list_type< std::allocator<int> >::container_type::iterator, true >;
|
||||
template class iterator
|
||||
template class iterator_from_iiterator
|
||||
<intrusive_list_type< std::allocator<int> >::container_type::iterator, false>;
|
||||
|
||||
}
|
||||
|
||||
+9
-7
@@ -12,18 +12,20 @@
|
||||
#define BOOST_CONTAINER_TEST_LIST_TEST_HEADER
|
||||
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <boost/container/detail/iterator.hpp>
|
||||
#include "check_equal_containers.hpp"
|
||||
#include <memory>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
#include "print_container.hpp"
|
||||
#include "input_from_forward_iterator.hpp"
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <boost/move/iterator.hpp>
|
||||
#include <string>
|
||||
#include <boost/move/make_unique.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <functional> //std::greater
|
||||
#include <string>
|
||||
|
||||
namespace boost{
|
||||
namespace container {
|
||||
namespace test{
|
||||
@@ -229,7 +231,7 @@ int list_test (bool copied_allocators_equal = true)
|
||||
boostlist.insert(boostlist.begin()
|
||||
,boost::make_move_iterator(&aux_vect[0])
|
||||
,boost::make_move_iterator(&aux_vect[50]));
|
||||
if(it_insert != boostlist.begin() || std::distance(it_insert, old_begin) != 50)
|
||||
if(it_insert != boostlist.begin() || boost::container::iterator_distance(it_insert, old_begin) != 50)
|
||||
return 1;
|
||||
|
||||
stdlist.insert(stdlist.begin(), &aux_vect2[0], &aux_vect2[50]);
|
||||
@@ -249,7 +251,7 @@ int list_test (bool copied_allocators_equal = true)
|
||||
it_insert = boostlist.insert(boostlist.end()
|
||||
,boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[0]))
|
||||
,boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[50])));
|
||||
if(std::distance(it_insert, boostlist.end()) != 50)
|
||||
if(boost::container::iterator_distance(it_insert, boostlist.end()) != 50)
|
||||
return 1;
|
||||
stdlist.insert(stdlist.end(), &aux_vect2[0], &aux_vect2[50]);
|
||||
if(!CheckEqualContainers(boostlist, stdlist))
|
||||
|
||||
@@ -12,7 +12,9 @@
|
||||
#include <boost/container/allocator.hpp>
|
||||
#include <boost/container/node_allocator.hpp>
|
||||
#include <boost/container/adaptive_pool.hpp>
|
||||
|
||||
#include <utility>
|
||||
#include <map>
|
||||
|
||||
#include "print_container.hpp"
|
||||
#include "movable_int.hpp"
|
||||
|
||||
+5
-5
@@ -13,16 +13,16 @@
|
||||
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include "check_equal_containers.hpp"
|
||||
#include <map>
|
||||
#include <functional>
|
||||
#include <utility>
|
||||
#include "print_container.hpp"
|
||||
#include <boost/container/detail/utilities.hpp>
|
||||
#include <boost/container/detail/pair.hpp>
|
||||
#include <boost/move/iterator.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <boost/move/make_unique.hpp>
|
||||
|
||||
#include <utility> //std::pair
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#include <boost/intrusive/detail/has_member_function_callable_with.hpp>
|
||||
#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME rebalance
|
||||
@@ -506,8 +506,8 @@ int map_test()
|
||||
std::pair<typename MyStdMultiMap::iterator, typename MyStdMultiMap::iterator> sret =
|
||||
stdmultimap.equal_range(stdmultimap.begin()->first);
|
||||
|
||||
if( std::distance(bret.first, bret.second) !=
|
||||
std::distance(sret.first, sret.second) ){
|
||||
if( boost::container::iterator_distance(bret.first, bret.second) !=
|
||||
boost::container::iterator_distance(sret.first, sret.second) ){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <boost/container/vector.hpp>
|
||||
#include <boost/container/stable_vector.hpp>
|
||||
#include <boost/container/detail/iterator.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
|
||||
#include <boost/container/vector.hpp>
|
||||
#include <boost/container/stable_vector.hpp>
|
||||
|
||||
#include "static_vector_test.hpp"
|
||||
|
||||
namespace boost {
|
||||
@@ -208,7 +208,7 @@ void test_pop_back_nd()
|
||||
template <typename It1, typename It2>
|
||||
void test_compare_ranges(It1 first1, It1 last1, It2 first2, It2 last2)
|
||||
{
|
||||
BOOST_TEST(std::distance(first1, last1) == std::distance(first2, last2));
|
||||
BOOST_TEST(boost::container::iterator_distance(first1, last1) == boost::container::iterator_distance(first2, last2));
|
||||
for ( ; first1 != last1 && first2 != last2 ; ++first1, ++first2 )
|
||||
BOOST_TEST(*first1 == *first2);
|
||||
}
|
||||
@@ -352,7 +352,7 @@ void test_insert(SV const& s, C const& c)
|
||||
static_vector<T, N> s1(s);
|
||||
|
||||
typename C::const_iterator it = c.begin();
|
||||
std::advance(it, n);
|
||||
boost::container::iterator_advance(it, n);
|
||||
typename static_vector<T, N>::iterator
|
||||
it1 = s1.insert(s1.begin() + i, c.begin(), it);
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <boost/container/string.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <boost/container/detail/algorithm.hpp> //equal()
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <cstddef>
|
||||
@@ -68,7 +68,7 @@ template<class StrVector1, class StrVector2>
|
||||
bool CheckEqualStringVector(StrVector1 *strvect1, StrVector2 *strvect2)
|
||||
{
|
||||
StringEqual comp;
|
||||
return std::equal(strvect1->begin(), strvect1->end(),
|
||||
return boost::container::algo_equal(strvect1->begin(), strvect1->end(),
|
||||
strvect2->begin(), comp);
|
||||
}
|
||||
|
||||
|
||||
+13
-9
@@ -12,7 +12,7 @@
|
||||
#define BOOST_CONTAINER_TEST_VECTOR_TEST_HEADER
|
||||
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
@@ -21,21 +21,25 @@
|
||||
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <boost/container/detail/mpl.hpp>
|
||||
#include "print_container.hpp"
|
||||
#include "check_equal_containers.hpp"
|
||||
#include "movable_int.hpp"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "emplace_test.hpp"
|
||||
#include "input_from_forward_iterator.hpp"
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <boost/move/iterator.hpp>
|
||||
#include <boost/move/make_unique.hpp>
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
#include "print_container.hpp"
|
||||
#include "check_equal_containers.hpp"
|
||||
#include "movable_int.hpp"
|
||||
#include "emplace_test.hpp"
|
||||
#include "input_from_forward_iterator.hpp"
|
||||
#include "insert_test.hpp"
|
||||
#include "container_common_tests.hpp"
|
||||
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace boost{
|
||||
namespace container {
|
||||
namespace test{
|
||||
@@ -168,7 +172,7 @@ int vector_test()
|
||||
boostvector.insert(boostvector.end()
|
||||
,boost::make_move_iterator(&aux_vect[0])
|
||||
,boost::make_move_iterator(aux_vect + 50));
|
||||
if(std::size_t(std::distance(insert_it, boostvector.end())) != 50) return 1;
|
||||
if(std::size_t(boost::container::iterator_distance(insert_it, boostvector.end())) != 50) return 1;
|
||||
stdvector.insert(stdvector.end(), aux_vect2, aux_vect2 + 50);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user