Opened 9 years ago

Closed 9 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:

Description

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.

Example:

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!

Change History (2)

comment:1 by Barend Gehrels, 9 years ago

Agreed, thanks. Done. Will be released in 1.55

comment:2 by Barend Gehrels, 9 years ago

Milestone: To Be DeterminedBoost 1.55.0
Resolution: fixed
Status: newclosed
Version: Boost 1.54.0Boost 1.55.0
Note: See TracTickets for help on using tickets.