mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-10 11:32:15 +00:00
Merge branch 'develop' into feature/relate
This commit is contained in:
@@ -11,7 +11,6 @@
|
||||
#define BOOST_GEOMETRY_ITERATORS_CONCATENATE_ITERATOR_HPP
|
||||
|
||||
#include <boost/type_traits.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/iterator.hpp>
|
||||
#include <boost/iterator/iterator_facade.hpp>
|
||||
#include <boost/iterator/iterator_categories.hpp>
|
||||
@@ -23,7 +22,7 @@ namespace boost { namespace geometry
|
||||
|
||||
|
||||
template <typename Iterator1, typename Iterator2, typename Value>
|
||||
struct concatenate_iterator
|
||||
class concatenate_iterator
|
||||
: public boost::iterator_facade
|
||||
<
|
||||
concatenate_iterator<Iterator1, Iterator2, Value>,
|
||||
@@ -35,8 +34,6 @@ private:
|
||||
Iterator1 m_it1, m_end1;
|
||||
Iterator2 m_it2;
|
||||
|
||||
struct enabler {};
|
||||
|
||||
public:
|
||||
typedef Iterator1 first_iterator_type;
|
||||
typedef Iterator2 second_iterator_type;
|
||||
@@ -57,17 +54,27 @@ public:
|
||||
|
||||
template <typename OtherIt1, typename OtherIt2, typename OtherValue>
|
||||
concatenate_iterator
|
||||
(concatenate_iterator<OtherIt1, OtherIt2, OtherValue> const& other,
|
||||
typename boost::enable_if_c
|
||||
<
|
||||
boost::is_convertible<OtherIt1, Iterator1>::value
|
||||
&& boost::is_convertible<OtherIt2, Iterator2>::value,
|
||||
enabler
|
||||
>::type = enabler())
|
||||
(concatenate_iterator<OtherIt1, OtherIt2, OtherValue> const& other)
|
||||
: m_it1(other.m_it1), m_end1(other.m_end1), m_it2(other.m_it2)
|
||||
{}
|
||||
{
|
||||
BOOST_STATIC_ASSERT
|
||||
( boost::is_convertible<OtherIt1, Iterator1>::value
|
||||
&& boost::is_convertible<OtherIt2, Iterator2>::value );
|
||||
}
|
||||
|
||||
template <typename OtherIt1, typename OtherIt2, typename OtherValue>
|
||||
concatenate_iterator
|
||||
operator=(concatenate_iterator<OtherIt1, OtherIt2, OtherValue> const& other)
|
||||
{
|
||||
BOOST_STATIC_ASSERT
|
||||
( boost::is_convertible<OtherIt1, Iterator1>::value
|
||||
&& boost::is_convertible<OtherIt2, Iterator2>::value );
|
||||
|
||||
m_it1 = other.m_it1;
|
||||
m_end1 = other.m_end1;
|
||||
m_it2 = other.m_it2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
friend class boost::iterator_core_access;
|
||||
@@ -75,7 +82,7 @@ private:
|
||||
template <typename It1, typename It2, typename V>
|
||||
friend class concatenate_iterator;
|
||||
|
||||
Value& dereference() const
|
||||
inline Value& dereference() const
|
||||
{
|
||||
if ( m_it1 == m_end1 )
|
||||
{
|
||||
@@ -84,12 +91,18 @@ private:
|
||||
return *m_it1;
|
||||
}
|
||||
|
||||
bool equal(concatenate_iterator const& other) const
|
||||
template <typename OtherIt1, typename OtherIt2, typename OtherValue>
|
||||
inline bool equal(concatenate_iterator
|
||||
<
|
||||
OtherIt1,
|
||||
OtherIt2,
|
||||
OtherValue
|
||||
> const& other) const
|
||||
{
|
||||
return m_it1 == other.m_it1 && m_it2 == other.m_it2;
|
||||
}
|
||||
|
||||
void increment()
|
||||
inline void increment()
|
||||
{
|
||||
if ( m_it1 == m_end1 )
|
||||
{
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#define BOOST_GEOMETRY_ITERATORS_FLATTEN_ITERATOR_HPP
|
||||
|
||||
#include <boost/type_traits.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/iterator.hpp>
|
||||
#include <boost/iterator/iterator_facade.hpp>
|
||||
#include <boost/iterator/iterator_categories.hpp>
|
||||
@@ -30,7 +29,7 @@ template
|
||||
typename AccessInnerBegin,
|
||||
typename AccessInnerEnd
|
||||
>
|
||||
struct flatten_iterator
|
||||
class flatten_iterator
|
||||
: public boost::iterator_facade
|
||||
<
|
||||
flatten_iterator
|
||||
@@ -48,8 +47,6 @@ private:
|
||||
OuterIterator m_outer_it, m_outer_end;
|
||||
InnerIterator m_inner_it;
|
||||
|
||||
struct enabler {};
|
||||
|
||||
public:
|
||||
typedef OuterIterator outer_iterator_type;
|
||||
typedef InnerIterator inner_iterator_type;
|
||||
@@ -82,16 +79,21 @@ public:
|
||||
OtherValue,
|
||||
OtherAccessInnerBegin,
|
||||
OtherAccessInnerEnd
|
||||
> const& other,
|
||||
typename boost::enable_if
|
||||
<
|
||||
boost::is_convertible<OtherValue*, Value*>,
|
||||
enabler
|
||||
>::type = enabler())
|
||||
> const& other)
|
||||
: m_outer_it(other.m_outer_it),
|
||||
m_outer_end(other.m_outer_end),
|
||||
m_inner_it(other.m_inner_it)
|
||||
{}
|
||||
{
|
||||
BOOST_STATIC_ASSERT( boost::is_convertible
|
||||
<
|
||||
OtherOuterIterator, OuterIterator
|
||||
>::value
|
||||
&& boost::is_convertible
|
||||
<
|
||||
OtherInnerIterator, InnerIterator
|
||||
>::value );
|
||||
|
||||
}
|
||||
|
||||
template
|
||||
<
|
||||
@@ -110,6 +112,15 @@ public:
|
||||
OtherAccessInnerEnd
|
||||
> const& other)
|
||||
{
|
||||
BOOST_STATIC_ASSERT( boost::is_convertible
|
||||
<
|
||||
OtherOuterIterator, OuterIterator
|
||||
>::value
|
||||
&& boost::is_convertible
|
||||
<
|
||||
OtherInnerIterator, InnerIterator
|
||||
>::value );
|
||||
|
||||
m_outer_it = other.m_outer_it;
|
||||
m_outer_end = other.m_outer_end;
|
||||
m_inner_it = other.m_inner_it;
|
||||
@@ -148,7 +159,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
Value& dereference() const
|
||||
inline Value& dereference() const
|
||||
{
|
||||
BOOST_ASSERT( m_outer_it != m_outer_end );
|
||||
BOOST_ASSERT( m_inner_it != AccessInnerEnd::apply(*m_outer_it) );
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#ifndef BOOST_GEOMETRY_ITERATORS_POINT_ITERATOR_HPP
|
||||
#define BOOST_GEOMETRY_ITERATORS_POINT_ITERATOR_HPP
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/geometry/iterators/dispatch/point_iterator.hpp>
|
||||
#include <boost/geometry/iterators/point_iterator_type.hpp>
|
||||
|
||||
@@ -222,17 +221,6 @@ private:
|
||||
return this;
|
||||
}
|
||||
|
||||
template <typename G1, typename G2>
|
||||
struct is_convertible
|
||||
: boost::is_convertible
|
||||
<
|
||||
typename dispatch::point_iterator_type<G1>::type,
|
||||
typename dispatch::point_iterator_type<G2>::type
|
||||
>
|
||||
{};
|
||||
|
||||
struct enabler {};
|
||||
|
||||
template <typename OtherGeometry> friend class point_iterator;
|
||||
template <typename G> friend inline point_iterator<G> points_begin(G&);
|
||||
template <typename G> friend inline point_iterator<G> points_end(G&);
|
||||
@@ -243,15 +231,16 @@ public:
|
||||
point_iterator() {}
|
||||
|
||||
template <typename OtherGeometry>
|
||||
point_iterator(point_iterator<OtherGeometry> const& other,
|
||||
typename boost::enable_if
|
||||
<
|
||||
is_convertible<OtherGeometry, Geometry>,
|
||||
enabler
|
||||
>::type = enabler())
|
||||
|
||||
point_iterator(point_iterator<OtherGeometry> const& other)
|
||||
: base(*other.base_ptr())
|
||||
{}
|
||||
{
|
||||
BOOST_STATIC_ASSERT
|
||||
( boost::is_convertible
|
||||
<
|
||||
typename dispatch::point_iterator_type<OtherGeometry>::type,
|
||||
typename dispatch::point_iterator_type<Geometry>::type
|
||||
>::value );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -54,10 +54,14 @@ struct test_concatenate_iterator
|
||||
{
|
||||
template <typename Container1, typename Container2>
|
||||
static inline void apply(Container1& c1, Container2& c2,
|
||||
std::string const& case_id)
|
||||
std::string const& case_id,
|
||||
std::string const& containers_id)
|
||||
{
|
||||
#ifdef GEOMETRY_TEST_DEBUG
|
||||
std::cout << "case id: " << case_id << std::endl;
|
||||
std::stringstream sstream;
|
||||
sstream << case_id << " [" << containers_id << "]";
|
||||
|
||||
std::cout << "case id: " << sstream.str() << std::endl;
|
||||
#endif
|
||||
typedef typename Container1::const_iterator const_iterator1;
|
||||
typedef typename Container2::const_iterator const_iterator2;
|
||||
@@ -146,6 +150,7 @@ struct test_concatenate_iterator
|
||||
std::max_element(const_begin, const_end);
|
||||
|
||||
BOOST_CHECK( it_max == const_it_max );
|
||||
BOOST_CHECK( *it_max == *const_it_max );
|
||||
|
||||
value_type old_value = *const_begin;
|
||||
value_type new_value = *it_max + 1;
|
||||
@@ -181,6 +186,7 @@ struct test_concatenate_iterator
|
||||
std::max_element(const_begin, const_end);
|
||||
|
||||
BOOST_CHECK( it_max == const_it_max );
|
||||
BOOST_CHECK( *it_max == *const_it_max );
|
||||
|
||||
value_type old_value = *begin2;
|
||||
value_type new_value = *it_max + 1;
|
||||
@@ -227,34 +233,45 @@ struct test_concatenate_iterator
|
||||
};
|
||||
|
||||
|
||||
template <typename Container1, typename Container2>
|
||||
void test_concatenation_of_containers(Container1& c1, Container2& c2,
|
||||
std::string const& containers_id)
|
||||
{
|
||||
#ifdef GEOMETRY_TEST_DEBUG
|
||||
std::cout << std::endl << std::endl;
|
||||
std::cout << "************************************" << std::endl
|
||||
<< " TESTING CONTAINERS COMBINATION: "
|
||||
<< containers_id << std::endl
|
||||
<< "************************************" << std::endl
|
||||
<< std::endl;
|
||||
#endif
|
||||
|
||||
c1.clear();
|
||||
c2.clear();
|
||||
test_concatenate_iterator::apply(c1, c2, "empty_both", containers_id);
|
||||
|
||||
c2 += 10,11,12,13,14,15,16,17,18,19,20;
|
||||
test_concatenate_iterator::apply(c1, c2, "empty_first", containers_id);
|
||||
|
||||
c2.clear();
|
||||
c1 += 0,1,2,3,4,5,6;
|
||||
test_concatenate_iterator::apply(c1, c2, "empty_second", containers_id);
|
||||
|
||||
c1.clear();
|
||||
c2.clear();
|
||||
c1 += 0,1,2,3,4,5,6;
|
||||
c2 += 10,11,12,13,14,15,16,17,18,19,20;
|
||||
test_concatenate_iterator::apply(c1, c2, "non_empty", containers_id);
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test_concatenate_iterator_all )
|
||||
{
|
||||
{
|
||||
std::vector<int> v;
|
||||
std::list<int> l;
|
||||
std::vector<int> v, vv;
|
||||
std::list<int> l, ll;
|
||||
|
||||
test_concatenate_iterator::apply(v, l, "empty_both");
|
||||
}
|
||||
{
|
||||
std::vector<int> v;
|
||||
std::list<int> l;
|
||||
l += 10,11,12,13,14,15,16,17,18,19,20;
|
||||
|
||||
test_concatenate_iterator::apply(v, l, "empty_first");
|
||||
}
|
||||
{
|
||||
std::vector<int> v;
|
||||
v += 0,1,2,3,4,5,6;
|
||||
std::list<int> l;
|
||||
|
||||
test_concatenate_iterator::apply(v, l, "empty_second");
|
||||
}
|
||||
{
|
||||
std::vector<int> v;
|
||||
v += 0,1,2,3,4,5,6;
|
||||
std::list<int> l;
|
||||
l += 10,11,12,13,14,15,16,17,18,19,20;
|
||||
|
||||
test_concatenate_iterator::apply(l, v, "non_empty");
|
||||
}
|
||||
test_concatenation_of_containers(v, vv, "VV");
|
||||
test_concatenation_of_containers(v, l, "VL");
|
||||
test_concatenation_of_containers(l, v, "LV");
|
||||
test_concatenation_of_containers(l, ll, "LL");
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <list>
|
||||
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/typeof/typeof.hpp>
|
||||
#include <boost/assign/std/vector.hpp>
|
||||
#include <boost/assign/std/list.hpp>
|
||||
#include <boost/assign/std/set.hpp>
|
||||
@@ -145,7 +146,7 @@ struct test_flatten_iterator
|
||||
{
|
||||
#ifdef GEOMETRY_TEST_DEBUG
|
||||
std::stringstream sstream;
|
||||
sstream << case_id << " " << "[" << container_id << "]";
|
||||
sstream << case_id << " [" << container_id << "]";
|
||||
|
||||
std::cout << "case id: " << sstream.str() << std::endl;
|
||||
#endif
|
||||
|
||||
@@ -228,6 +228,15 @@ struct test_point_iterator_of_geometry
|
||||
const_begin = begin;
|
||||
const_end = end;
|
||||
|
||||
// testing equality/inequality comparison
|
||||
BOOST_CHECK ( begin == const_begin );
|
||||
BOOST_CHECK ( end == const_end );
|
||||
if ( begin != end )
|
||||
{
|
||||
BOOST_CHECK ( begin != const_end );
|
||||
BOOST_CHECK ( const_begin != end );
|
||||
}
|
||||
|
||||
// testing dereferencing/assignment
|
||||
if ( begin != end )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user