Modify

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: barendgehrels
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!

Attachments (0)

Change History (2)

comment:1 Changed 4 years ago by barendgehrels

Agreed, thanks. Done. Will be released in 1.55

comment:2 Changed 4 years ago by barendgehrels

  • Milestone changed from To Be Determined to Boost 1.55.0
  • Resolution set to fixed
  • Status changed from new to closed
  • Version changed from Boost 1.54.0 to Boost 1.55.0

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain barendgehrels.
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.