[Boost-bugs] [Boost C++ Libraries] #8969: boost::geometry::model::point single argument constructor should be explicit

Subject: [Boost-bugs] [Boost C++ Libraries] #8969: boost::geometry::model::point single argument constructor should be explicit
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-08-05 21:23:57


#8969: boost::geometry::model::point single argument constructor should be
explicit
-----------------------------------------------+---------------------------
 Reporter: Jared Russell <jaredrussell341@…> | Owner: barendgehrels
     Type: Feature Requests | Status: new
Milestone: To Be Determined | Component: geometry
  Version: Boost 1.54.0 | Severity: Problem
 Keywords: |
-----------------------------------------------+---------------------------
 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!
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/8969>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:13 UTC