Changes between Initial Version and Version 1 of Ticket #11739
- Timestamp:
- Feb 16, 2017, 10:53:21 AM (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #11739
- Property Cc added
-
Ticket #11739 – Description
initial v1 3 3 The fix appears to be easy, change this code 4 4 5 {{{ 5 6 template <typename T> BOOST_FORCEINLINE 6 7 point2<double> operator/(const point2<T>& p, double t) { return t==0 ? point2<double>(0,0):point2<double>(p.x/t,p.y/t); } 8 }}} 7 9 8 10 to 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. … … 10 12 A possibly safer alternative is to cast the result back to point2<T>, ie; 11 13 14 {{{ 12 15 template <typename T> BOOST_FORCEINLINE 13 16 point2<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 }}} 14 18 15 19 This 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).