Changes between Initial Version and Version 1 of Ticket #11739


Ignore:
Timestamp:
Feb 16, 2017, 10:53:21 AM (6 years ago)
Author:
Mateusz Loskot
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #11739

    • Property Cc mateusz@… added
  • Ticket #11739 – Description

    initial v1  
    33The fix appears to be easy, change this code
    44
     5{{{
    56template <typename T> BOOST_FORCEINLINE
    67point2<double> operator/(const point2<T>& p, double t)      { return t==0 ? point2<double>(0,0):point2<double>(p.x/t,p.y/t); }
     8}}}
    79
    810to operate on T instead of double.  But, that seems overly simple so I am trying to figure out why this code was written this way in the first place.
     
    1012A possibly safer alternative is to cast the result back to point2<T>, ie;
    1113
     14{{{
    1215template <typename T> BOOST_FORCEINLINE
    1316point2<double> operator/(const point2<T>& p, double t)      { return t==0 ? point2<T>(0,0):point2<T>(T(p.x/t),T(p.y/t)); }
     17}}}
    1418
    1519This change makes the / operator act the same as the /= operator, which is also hard coded to double, but because it's a member, doesn't yield a new type, so it's probably fine (other than the fact that I asked for floats and am getting double operations).