Opened 9 years ago

Closed 9 years ago

#9386 closed Bugs (fixed)

Compilation error with polygon and multi_array

Reported by: voodooattack@… Owned by: Andrii Sydorchuk
Milestone: Boost 1.56.0 Component: polygon
Version: Boost 1.54.0 Severity: Problem
Keywords: polygon multi_array Cc:

Description

With this piece of code:

#include <boost/multi_array.hpp>
#include <boost/polygon/polygon.hpp>

int main()
{
	typedef boost::polygon::polygon_45_with_holes_data<int> polygon;
	typedef boost::polygon::polygon_traits<polygon>::point_type point;
	
	point centroid;
	polygon poly;
	
	boost::polygon::center(c.centroid, c.poly);
}

If you include the headers in the following order:

#include <boost/multi_array.hpp>
#include <boost/polygon/polygon.hpp>

..it breaks, if you reverse them it works:

#include <boost/polygon/polygon.hpp>
#include <boost/multi_array.hpp>

Attachments (1)

9386.diff (1.6 KB ) - added by Andrii Sydorchuk 9 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 by anonymous, 9 years ago

The compilation error is:

/usr/local/include/boost/polygon/polygon_traits.hpp:1429:26: error: no match for call to ‘(boost::multi_array_types::extent_gen {aka boost::detail::multi_array::extent_gen<0ul>}) (boost::polygon::rectangle_data<int>&, const boost::polygon::polygon_45_with_holes_data<int>&)’

comment:2 by Andrii Sydorchuk, 9 years ago

Owner: changed from Lucanus Simonson to Andrii Sydorchuk
Status: newassigned

comment:3 by Andrii Sydorchuk, 9 years ago

The problem here is with ADL (argument dependent lookup). The issues is explained with an example here: http://stackoverflow.com/questions/2958648/what-are-the-pitfalls-of-adl. From what I understood, there is no way to fix this permanently, as I can not rename the Boost.Polygon method because it's part of the public interface. The possible solution will be to use the following directive at the top of your file: #define BOOST_MULTI_ARRAY_NO_GENERATORS 1

comment:4 by Andrii Sydorchuk, 9 years ago

Resolution: wontfix
Status: assignedclosed

I am marking the issue as "wontfix", as it requires the changes to the C++ standard. Here is some additional reading from Dave Abrahams: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3490.html

comment:5 by Andrii Sydorchuk, 9 years ago

Milestone: To Be DeterminedBoost 1.56.0
Resolution: wontfix
Status: closedreopened

I've found the way to fix the issue by changing the order of method definitions inside the Polygon library. Please use the attached patch.

by Andrii Sydorchuk, 9 years ago

Attachment: 9386.diff added

comment:6 by Andrii Sydorchuk, 9 years ago

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.