Boost C++ Libraries: Ticket #5580: BOOST_PP_MUL documentation regarding efficiency is confusing https://svn.boost.org/trac10/ticket/5580 <p> From </p> <p> <a href="http://www.boost.org/libs/preprocessor/doc/ref/mul.html">http://www.boost.org/libs/preprocessor/doc/ref/mul.html</a> </p> <p> "This macro is the most efficient when x is less than or equal to y. However, the efficiency gain is not worth actually comparing the two arguments prior to invocation. In other words, x should be the value that is most likely to be the largest of the two operands." </p> <p> The first sentence suggest that x &lt;= y is more efficient; the last sentence suggests that x &gt;= y is more efficient. I'm confused :( </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5580 Trac 1.4.3 Jeffrey Lee Hellrung, Jr. <jeffrey.hellrung@…> Sun, 29 May 2011 20:49:50 GMT <link>https://svn.boost.org/trac10/ticket/5580#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5580#comment:1</guid> <description> <p> It looks like the exact same wording is used for all of </p> <p> BOOST_PP_ADD <br /> BOOST_PP_ADD_D <br /> BOOST_PP_MUL <br /> BOOST_PP_MUL_D <br /> </p> </description> <category>Ticket</category> </item> <item> <author>alex.cole@…</author> <pubDate>Thu, 13 Nov 2014 10:43:17 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5580#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5580#comment:2</guid> <description> <p> I just wanted to bump this ticket, since I came across the exact same thing in the BOOST_PP_ADD documentation today. The ticket already notes that macro as well, so I figured this was better than a new ticket. </p> </description> <category>Ticket</category> </item> <item> <author>Alex Cole <alex.cole@…></author> <pubDate>Thu, 13 Nov 2014 12:10:01 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5580#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5580#comment:3</guid> <description> <p> I've done some digging, and it seems BOOST_PP_ADD internally works by decrementing the second parameter while incrementing the first parameter in a BOOST_PP_WHILE loop until the second parameter is zero. I'm not the author, but this to me implies that having the second parameter likely to be smaller is the most efficient method, as it will result in slightly less iterations. </p> <p> So by my reading of the code, the second statement that "In other words, x should be the value that is most likely to be the largest of the two operands." is the correct one. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Edward Diener</dc:creator> <pubDate>Fri, 05 Dec 2014 05:17:25 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5580#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5580#comment:4</guid> <description> <p> I have updated this on the 'develop' branch and will update the 'master' branch before the next release. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Edward Diener</dc:creator> <pubDate>Sun, 17 May 2015 04:58:55 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5580#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5580#comment:5</guid> <description> <p> This has ben updated so that the correct explanation is in the Boost 1.58 release. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Edward Diener</dc:creator> <pubDate>Sun, 17 May 2015 04:59:03 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/5580#comment:6 https://svn.boost.org/trac10/ticket/5580#comment:6 <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">fixed</span> </li> </ul> Ticket