Boost C++ Libraries: Ticket #6511: Division by scalar should use enable_if<> https://svn.boost.org/trac10/ticket/6511 <p> file: vector_expression.hpp lines 1409 through 1417 function: operator/( vector, scalar) </p> <p> Should be using the enable_if&lt;&gt; macros just like the operator*() in lines 1397 through 1407 (just above it). Doing so allows further overloading of operator/() for other types. Suggested change is... </p> <p> Before: </p> <div class="wiki-code"><div class="code"><pre> <span class="o">//</span> <span class="p">(</span><span class="n">v</span> <span class="o">/</span> <span class="n">t</span><span class="p">)</span> <span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">v</span> <span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">/</span> <span class="n">t</span> <span class="n">template</span><span class="o">&lt;</span><span class="k">class</span> <span class="nc">E1</span><span class="p">,</span> <span class="k">class</span> <span class="nc">T2</span><span class="o">&gt;</span> <span class="n">BOOST_UBLAS_INLINE</span> <span class="n">typename</span> <span class="n">vector_binary_scalar2_traits</span><span class="o">&lt;</span><span class="n">E1</span><span class="p">,</span> <span class="n">const</span> <span class="n">T2</span><span class="p">,</span> <span class="n">scalar_divides</span><span class="o">&lt;</span><span class="n">typename</span> <span class="n">E1</span><span class="p">::</span><span class="n">value_type</span><span class="p">,</span> <span class="n">T2</span><span class="o">&gt;</span> <span class="o">&gt;</span><span class="p">::</span><span class="n">result_type</span> <span class="n">operator</span> <span class="o">/</span> <span class="p">(</span><span class="n">const</span> <span class="n">vector_expression</span><span class="o">&lt;</span><span class="n">E1</span><span class="o">&gt;</span> <span class="o">&amp;</span><span class="n">e1</span><span class="p">,</span> <span class="n">const</span> <span class="n">T2</span> <span class="o">&amp;</span><span class="n">e2</span><span class="p">)</span> <span class="p">{</span> <span class="n">typedef</span> <span class="n">typename</span> <span class="n">vector_binary_scalar2_traits</span><span class="o">&lt;</span><span class="n">E1</span><span class="p">,</span> <span class="n">const</span> <span class="n">T2</span><span class="p">,</span> <span class="n">scalar_divides</span><span class="o">&lt;</span><span class="n">typename</span> <span class="n">E1</span><span class="p">::</span><span class="n">value_type</span><span class="p">,</span> <span class="n">T2</span><span class="o">&gt;</span> <span class="o">&gt;</span><span class="p">::</span><span class="n">expression_type</span> <span class="n">expression_type</span><span class="p">;</span> <span class="k">return</span> <span class="n">expression_type</span> <span class="p">(</span><span class="n">e1</span> <span class="p">(),</span> <span class="n">e2</span><span class="p">);</span> <span class="p">}</span> </pre></div></div><p> After: </p> <div class="wiki-code"><div class="code"><pre> <span class="o">//</span> <span class="p">(</span><span class="n">v</span> <span class="o">/</span> <span class="n">t</span><span class="p">)</span> <span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">v</span> <span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">/</span> <span class="n">t</span> <span class="n">template</span><span class="o">&lt;</span><span class="k">class</span> <span class="nc">E1</span><span class="p">,</span> <span class="k">class</span> <span class="nc">T2</span><span class="o">&gt;</span> <span class="n">BOOST_UBLAS_INLINE</span> <span class="n">typename</span> <span class="n">enable_if</span><span class="o">&lt;</span> <span class="n">is_convertible</span><span class="o">&lt;</span><span class="n">T2</span><span class="p">,</span> <span class="n">typename</span> <span class="n">E1</span><span class="p">::</span><span class="n">value_type</span> <span class="o">&gt;</span><span class="p">,</span> <span class="n">typename</span> <span class="n">vector_binary_scalar2_traits</span><span class="o">&lt;</span><span class="n">E1</span><span class="p">,</span> <span class="n">const</span> <span class="n">T2</span><span class="p">,</span> <span class="n">scalar_multiplies</span><span class="o">&lt;</span><span class="n">typename</span> <span class="n">E1</span><span class="p">::</span><span class="n">value_type</span><span class="p">,</span> <span class="n">T2</span><span class="o">&gt;</span> <span class="o">&gt;</span><span class="p">::</span><span class="n">result_type</span> <span class="o">&gt;</span><span class="p">::</span><span class="nb">type</span> <span class="n">typename</span> <span class="n">vector_binary_scalar2_traits</span><span class="o">&lt;</span><span class="n">E1</span><span class="p">,</span> <span class="n">const</span> <span class="n">T2</span><span class="p">,</span> <span class="n">scalar_divides</span><span class="o">&lt;</span><span class="n">typename</span> <span class="n">E1</span><span class="p">::</span><span class="n">value_type</span><span class="p">,</span> <span class="n">T2</span><span class="o">&gt;</span> <span class="o">&gt;</span><span class="p">::</span><span class="n">result_type</span> <span class="n">operator</span> <span class="o">/</span> <span class="p">(</span><span class="n">const</span> <span class="n">vector_expression</span><span class="o">&lt;</span><span class="n">E1</span><span class="o">&gt;</span> <span class="o">&amp;</span><span class="n">e1</span><span class="p">,</span> <span class="n">const</span> <span class="n">T2</span> <span class="o">&amp;</span><span class="n">e2</span><span class="p">)</span> <span class="p">{</span> <span class="n">typedef</span> <span class="n">typename</span> <span class="n">vector_binary_scalar2_traits</span><span class="o">&lt;</span><span class="n">E1</span><span class="p">,</span> <span class="n">const</span> <span class="n">T2</span><span class="p">,</span> <span class="n">scalar_divides</span><span class="o">&lt;</span><span class="n">typename</span> <span class="n">E1</span><span class="p">::</span><span class="n">value_type</span><span class="p">,</span> <span class="n">T2</span><span class="o">&gt;</span> <span class="o">&gt;</span><span class="p">::</span><span class="n">expression_type</span> <span class="n">expression_type</span><span class="p">;</span> <span class="k">return</span> <span class="n">expression_type</span> <span class="p">(</span><span class="n">e1</span> <span class="p">(),</span> <span class="n">e2</span><span class="p">);</span> <span class="p">}</span> </pre></div></div> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6511 Trac 1.4.3 Gunter Mon, 27 Aug 2012 23:31:07 GMT <link>https://svn.boost.org/trac10/ticket/6511#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6511#comment:1</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/80270" title=" boost/numeric/ublas/vector_expression.hpp - use enable_if for ...">[80270]</a>) boost/numeric/ublas/vector_expression.hpp - use enable_if for operator/(vector, scalar), see <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6511" title="#6511: Bugs: Division by scalar should use enable_if&lt;&gt; (closed: fixed)">#6511</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Gunter</dc:creator> <pubDate>Sun, 16 Sep 2012 20:59:41 GMT</pubDate> <title>status, version changed https://svn.boost.org/trac10/ticket/6511#comment:2 https://svn.boost.org/trac10/ticket/6511#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>version</strong> <span class="trac-field-old">Boost 1.48.0</span> → <span class="trac-field-new">Boost 1.52.0</span> </li> </ul> Ticket Gunter Sun, 16 Sep 2012 21:02:12 GMT version, milestone changed https://svn.boost.org/trac10/ticket/6511#comment:3 https://svn.boost.org/trac10/ticket/6511#comment:3 <ul> <li><strong>version</strong> <span class="trac-field-old">Boost 1.52.0</span> → <span class="trac-field-new">Boost 1.48.0</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.52.0</span> </li> </ul> <p> updated wrong field <sup></sup> </p> Ticket Gunter Tue, 18 Sep 2012 21:07:16 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/6511#comment:4 https://svn.boost.org/trac10/ticket/6511#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/80588" title="merge ...">[80588]</a>) merge <a class="changeset" href="https://svn.boost.org/trac10/changeset/61880" title="see #4202: fixed some typos and grammar mistakes ">[61880]</a>,<a class="changeset" href="https://svn.boost.org/trac10/changeset/75560" title="added new tests ">[75560]</a>,<a class="changeset" href="https://svn.boost.org/trac10/changeset/80267" title=" boost/numeric/ublas/triangular.hpp - applied patch, see #4024 ...">[80267]</a>,<a class="changeset" href="https://svn.boost.org/trac10/changeset/80268" title="boost/numeric/ublas/traits.hpp - apply patch, see #6514 ">[80268]</a>,<a class="changeset" href="https://svn.boost.org/trac10/changeset/80269" title=" boost/numeric/ublas/operation: num_rows.hpp, num_columns.hpp - use ...">[80269]</a>,<a class="changeset" href="https://svn.boost.org/trac10/changeset/80270" title=" boost/numeric/ublas/vector_expression.hpp - use enable_if for ...">[80270]</a>,<a class="changeset" href="https://svn.boost.org/trac10/changeset/80399" title="libs/numeric/ublas/test/test_inplace_solve.cpp: see #4024 - remove ...">[80399]</a>,<a class="changeset" href="https://svn.boost.org/trac10/changeset/80403" title="boost/numeric/ublas/matrix_sparse.hpp : fix ...">[80403]</a>,<a class="changeset" href="https://svn.boost.org/trac10/changeset/80483" title=" boost/numeric/ublas/traits.hpp, ...">[80483]</a>,<a class="changeset" href="https://svn.boost.org/trac10/changeset/80485" title=" * libs/numeric/ublas/test/utils.hpp : see #7296, improved macros * ...">[80485]</a>,<a class="changeset" href="https://svn.boost.org/trac10/changeset/80507" title=" * libs/numeric/ublas/tests/utils.hpp: see #7296 - replace __func__ by ...">[80507]</a>,<a class="changeset" href="https://svn.boost.org/trac10/changeset/80563" title=" * libs/numeric/ublas/test/test_ticket7296.cpp: see #7296 - add ...">[80563]</a> into release branch </p> <ul><li>fix <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6511" title="#6511: Bugs: Division by scalar should use enable_if&lt;&gt; (closed: fixed)">#6511</a>, fix <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6514" title="#6514: Bugs: [ublas] fix for has_trivial_constructor (closed: fixed)">#6514</a>, fix <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7296" title="#7296: Bugs: Bug-fix and improvements to test utility functions (closed: fixed)">#7296</a>, fix <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7297" title="#7297: Patches: Make the free functions 'num_columns' and 'num_rows' support the uBLAS ... (closed: fixed)">#7297</a>, </li></ul><ul><li>see <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4024" title="#4024: Patches: improve performance of inplace_solve (closed: fixed)">#4024</a> </li></ul> Ticket Sean Reilly <campreilly@…> Sun, 30 Dec 2012 19:23:38 GMT <link>https://svn.boost.org/trac10/ticket/6511#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6511#comment:5</guid> <description> <p> Sorry to do this to you after the ticket has already closed... </p> <p> But, did you happen to make the corresponding change to matrix_expression.hpp? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Gunter</dc:creator> <pubDate>Fri, 04 Jan 2013 20:54:52 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6511#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6511#comment:6</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/6511#comment:5" title="Comment 5">Sean Reilly &lt;campreilly@…&gt;</a>: </p> <blockquote class="citation"> <p> But, did you happen to make the corresponding change to matrix_expression.hpp? </p> </blockquote> <p> No, only vector_expression has been patched for this ticket. </p> </description> <category>Ticket</category> </item> </channel> </rss>