Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r73327 - in trunk: boost/geometry/algorithms libs/geometry/test/algorithms
From: barend.gehrels_at_[hidden]
Date: 2011-07-24 06:26:03


Author: barendgehrels
Date: 2011-07-24 06:25:53 EDT (Sun, 24 Jul 2011)
New Revision: 73327
URL: http://svn.boost.org/trac/boost/changeset/73327

Log:
Fixed convert for two array-types (which cannot be copied in non-MSVC)
Text files modified:
   trunk/boost/geometry/algorithms/convert.hpp | 12 +++++++++---
   trunk/libs/geometry/test/algorithms/convert.cpp | 10 ++++++++++
   2 files changed, 19 insertions(+), 3 deletions(-)

Modified: trunk/boost/geometry/algorithms/convert.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/convert.hpp (original)
+++ trunk/boost/geometry/algorithms/convert.hpp 2011-07-24 06:25:53 EDT (Sun, 24 Jul 2011)
@@ -19,6 +19,7 @@
 
 #include <boost/numeric/conversion/cast.hpp>
 #include <boost/range.hpp>
+#include <boost/type_traits/is_array.hpp>
 
 #include <boost/geometry/arithmetic/arithmetic.hpp>
 #include <boost/geometry/algorithms/append.hpp>
@@ -361,8 +362,11 @@
 
 /*!
 \brief Converts one geometry to another geometry
-\details The convert algorithm converts one geometry, e.g. a BOX, to another geometry, e.g. a RING. This only
-if it is possible and applicable.
+\details The convert algorithm converts one geometry, e.g. a BOX, to another
+geometry, e.g. a RING. This only if it is possible and applicable.
+If the point-order is different, or the closure is different between two
+geometry types, it will be converted correctly by explicitly reversing the
+points or closing or opening the polygon rings.
 \ingroup convert
 \tparam Geometry1 \tparam_geometry
 \tparam Geometry2 \tparam_geometry
@@ -378,7 +382,9 @@
 
     dispatch::convert
         <
- boost::is_same<Geometry1, Geometry2>::value, // && boost::has_assign<Geometry2>::value,
+ boost::is_same<Geometry1, Geometry2>::value
+ // && boost::has_assign<Geometry2>::value, -- type traits extensions
+ && ! boost::is_array<Geometry1>::value,
             typename tag_cast<typename tag<Geometry1>::type, multi_tag>::type,
             typename tag_cast<typename tag<Geometry2>::type, multi_tag>::type,
             dimension<Geometry1>::type::value,

Modified: trunk/libs/geometry/test/algorithms/convert.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/convert.cpp (original)
+++ trunk/libs/geometry/test/algorithms/convert.cpp 2011-07-24 06:25:53 EDT (Sun, 24 Jul 2011)
@@ -221,6 +221,15 @@
     test_mixed_point_types<Point2, Point1>();
 }
 
+void test_array()
+{
+ int a[2] = {1, 2};
+ int b[2];
+ bg::convert(a, b);
+ BOOST_CHECK_EQUAL(b[0], 1);
+ BOOST_CHECK_EQUAL(b[1], 2);
+}
+
 int test_main(int, char* [])
 {
     test_mixed_types
@@ -234,5 +243,6 @@
             bg::model::point<float, 2, bg::cs::cartesian>
>();
 
+ test_array();
     return 0;
 }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk