Opened 4 years ago

Closed 4 years ago

#8969 closed Feature Requests (fixed)

boost::geometry::model::point single argument constructor should be explicit

Reported by: Jared Russell <jaredrussell341@…> Owned by: Barend Gehrels
Milestone: Boost 1.55.0 Component: geometry
Version: Boost 1.55.0 Severity: Problem
Keywords: Cc:


In boost/geometry/geometries/point.hpp, the function:

point::point(CoordinateType? const & v0, CoordinateType? const & v1 = 0, CoordinateType? const & v2 = 0)

has default arguments. Because there is a single argument case, we can use this function for implicit conversion. This is probably not the desired behavior. As a result, any numerical type can be implicitly converted to a point whether you meant to or not. Adding the "explicit" keyword resolves the issue.


namespace bgm = boost::geometry::model;
namespace bgc = boost::geometry::cs;

bgm::point<double, 2, bgc::cartesian> ll(0.0, 0.0); // lower left
bgm::point<double, 2, bgc::cartesian> ur(100.0, 100.0); // upper right

bgm::box<bgm::point<double, 2, bgc::cartesian> > myBox(11,ur); // Oops!  literal 11, not "ll".  But it will compile!

Attachments (0)

Change History (2)

comment:1 Changed 4 years ago by Barend Gehrels

Agreed, thanks. Done. Will be released in 1.55

comment:2 Changed 4 years ago by Barend Gehrels

Milestone: To Be DeterminedBoost 1.55.0
Resolution: fixed
Status: newclosed
Version: Boost 1.54.0Boost 1.55.0

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Barend Gehrels.
The resolution will be deleted.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.