Boost C++ Libraries: Ticket #11739: operator / for point2 is hard coded to operate on type double https://svn.boost.org/trac10/ticket/11739 <p> When using boost::gil::point2&lt;float&gt;, applying a division operation results in a point2&lt;double&gt;. This is undesirable. </p> <p> The fix appears to be easy, change this code </p> <pre class="wiki">template &lt;typename T&gt; BOOST_FORCEINLINE point2&lt;double&gt; operator/(const point2&lt;T&gt;&amp; p, double t) { return t==0 ? point2&lt;double&gt;(0,0):point2&lt;double&gt;(p.x/t,p.y/t); } </pre><p> 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. </p> <p> A possibly safer alternative is to cast the result back to point2&lt;T&gt;, ie; </p> <pre class="wiki">template &lt;typename T&gt; BOOST_FORCEINLINE point2&lt;double&gt; operator/(const point2&lt;T&gt;&amp; p, double t) { return t==0 ? point2&lt;T&gt;(0,0):point2&lt;T&gt;(T(p.x/t),T(p.y/t)); } </pre><p> 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). </p> <p> While we're at it, I also find it weird that this code is protecting against division by zero, but that's a different problem. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11739 Trac 1.4.3 Mateusz Loskot Thu, 16 Feb 2017 10:53:21 GMT description changed; cc set https://svn.boost.org/trac10/ticket/11739#comment:1 https://svn.boost.org/trac10/ticket/11739#comment:1 <ul> <li><strong>cc</strong> <span class="trac-author">mateusz@…</span> added </li> <li><strong>description</strong> modified (<a href="/trac10/ticket/11739?action=diff&amp;version=1">diff</a>) </li> </ul> Ticket Stefan Seefeld Sat, 01 Jul 2017 21:17:35 GMT owner changed https://svn.boost.org/trac10/ticket/11739#comment:2 https://svn.boost.org/trac10/ticket/11739#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Hailin Jin</span> to <span class="trac-author">Stefan Seefeld</span> </li> </ul> Ticket Mateusz Loskot Sat, 13 Oct 2018 19:48:59 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/11739#comment:3 https://svn.boost.org/trac10/ticket/11739#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">duplicate</span> </li> </ul> <p> The ticket move to <a class="ext-link" href="https://github.com/boostorg/gil/issues/153"><span class="icon">​</span>https://github.com/boostorg/gil/issues/153</a> </p> Ticket