Opened 4 years ago

Last modified 4 years ago

#13539 new Bugs

Boost Polygon - MSVC 2017 - Ambiguous call to size() function

Reported by: Kai Benndorf <kai.benndorf@…> Owned by: Lucanus Simonson
Milestone: To Be Determined Component: polygon
Version: Boost 1.67.0 Severity: Regression
Keywords: Cc: Kai, Benndorf

Description

We are currently switching our compiler from MSVC 2012 to MSVC 2017. Now I have problems compiling out application using Boost Polygon. I get the following error:

c:\khand\win64\include\boost\polygon\polygon_traits.hpp(606): error C2668: "boost::polygon::size": ambiguous call to overloaded function c:\khand\win64\include\boost\polygon\polygon_traits.hpp(467): note: could be "unsigned int64 boost::polygon::size<polygon_type>(const T &)"

with [

polygon_type=DESIGN::GTL::Polygon, T=DESIGN::GTL::Polygon

]

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.13.26128\include\xutility(1611): note: or "unsigned int64 std::size<polygon_type>(const _Container &)" [bei der Verwendung der argumentbezogenen Suche gefunden]

with [

polygon_type=DESIGN::GTL::Polygon, _Container=DESIGN::GTL::Polygon

]

In size() function in polygon_traits.hpp conflicts with the now in C++ standard contained std::size().

I could solve the problem by using the completed name boost:polygon::size() in polygon_traits.hpp. Please see appended diff.

Change History (1)

comment:1 by Kai Benndorf <kai.benndorf@…>, 4 years ago

It was not possible to append a file, so the diff comes here:

Index: polygon_traits.hpp

===================================================================

--- polygon_traits.hpp	(revision 511)

+++ polygon_traits.hpp	(working copy)

@@ -603,7 +603,7 @@

                        polygon_type>::type &
   convolve(polygon_type& polygon, const point_type& point) {
     std::vector<typename std::iterator_traits<typename polygon_traits<polygon_type>::iterator_type>::value_type> points;
-    points.reserve(size(polygon));
+    points.reserve(boost::polygon::size(polygon));
     for(typename polygon_traits<polygon_type>::iterator_type iter = begin_points(polygon);
         iter != end_points(polygon); ++iter) {
       points.push_back(*iter);
@@ -689,7 +689,7 @@

   typename enable_if< typename is_any_mutable_polygon_without_holes_type<polygon_type>::type, polygon_type>::type &
   scale_up(polygon_type& polygon, typename coordinate_traits<typename polygon_traits<polygon_type>::coordinate_type>::unsigned_area_type factor) {
     std::vector<typename std::iterator_traits<typename polygon_traits<polygon_type>::iterator_type>::value_type> points;
-    points.reserve(size(polygon));
+    points.reserve(boost::polygon::size(polygon));
     for(typename polygon_traits<polygon_type>::iterator_type iter = begin_points(polygon);
         iter != end_points(polygon); ++iter) {
       points.push_back(*iter);
@@ -728,7 +728,7 @@

     polygon_type>::type &
   scale_down(polygon_type& polygon, typename coordinate_traits<typename polygon_traits<polygon_type>::coordinate_type>::unsigned_area_type factor) {
     std::vector<typename std::iterator_traits<typename polygon_traits<polygon_type>::iterator_type>::value_type> points;
-    points.reserve(size(polygon));
+    points.reserve(boost::polygon::size(polygon));
     for(typename polygon_traits<polygon_type>::iterator_type iter = begin_points(polygon);
         iter != end_points(polygon); ++iter) {
       points.push_back(*iter);
@@ -903,7 +903,7 @@

     polygon_type>::type &
   scale(polygon_type& polygon, double factor) {
     std::vector<typename std::iterator_traits<typename polygon_traits<polygon_type>::iterator_type>::value_type> points;
-    points.reserve(size(polygon));
+    points.reserve(boost::polygon::size(polygon));
     for(typename polygon_traits<polygon_type>::iterator_type iter = begin_points(polygon);
         iter != end_points(polygon); ++iter) {
       points.push_back(*iter);
Note: See TracTickets for help on using tickets.