Modify

Ticket #8969 (closed Feature Requests: fixed)

Opened 9 months ago

Last modified 8 months ago

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

Change History

comment:1 Changed 8 months ago by barendgehrels

Agreed, thanks. Done. Will be released in 1.55

comment:2 Changed 8 months ago by barendgehrels

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

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
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.