Boost C++ Libraries: Ticket #3873: Promote Existing is_sorted Algorithm Detail to First-class Template / Track C++1x N3000 is_sorted{_until} https://svn.boost.org/trac10/ticket/3873 <p> This is in reference to the long thread at: </p> <blockquote> <p> <a class="ext-link" href="http://lists.boost.org/Archives/boost/2010/01/161121.php"><span class="icon">​</span>http://lists.boost.org/Archives/boost/2010/01/161121.php</a> </p> </blockquote> <p> The original proposal was as follows: </p> <blockquote> <p> The creasing algorithm templates define four template functions for determining the order properties of sequences, specifically: </p> </blockquote> <p> </p> <ul><li>Increasing </li><li>Decreasing </li><li>Strictly Increasing </li><li>Strictly Decreasing </li></ul><p> </p> <blockquote> <p> The implementation is a fairly trivial composition of the STL adjacent_find, not2 and {greater,less,greater_equal,less_equal}. For the purposes of sequence ordering validation, using these templates is more efficient and straightforward than creating a temporary, sorted version of some sequence and comparing it against the original sequence. </p> </blockquote> <p> </p> <blockquote> <p> Example: </p> <blockquote> <p> bool <a class="missing wiki">CheckPoints</a>(const Points &amp; inPoints) { </p> <blockquote> <p> const bool strictlyIncreasing = is_strictly_increasing(inPoints.begin(), inPoints.end()); </p> </blockquote> </blockquote> </blockquote> <p> </p> <blockquote> <blockquote> <blockquote> <p> if (!strictlyIncreasing) { </p> <blockquote> <p> cerr &lt;&lt; "Points must be in increasing order with " </p> <blockquote> <p> "no duplicate values." </p> </blockquote> <p> &lt;&lt; endl; </p> </blockquote> <p> } </p> </blockquote> </blockquote> </blockquote> <p> </p> <blockquote> <blockquote> <blockquote> <p> return strictlyIncreasing; </p> </blockquote> <p> } </p> </blockquote> </blockquote> <p> </p> <blockquote> <p> The review files are available in both Sandbox and Vault: </p> </blockquote> <p> </p> <blockquote> <p> Sandbox: </p> </blockquote> <p> </p> <blockquote> <blockquote> <p> boost/algorithm/creasing.hpp libs/algorithm/creasing/example/creasing_ex.cpp libs/algorithm/creasing/example/Jamfile libs/algorithm/creasing/test/creasing_test.cpp libs/algorithm/creasing/test/Jamfile.v2 </p> </blockquote> </blockquote> <p> </p> <blockquote> <p> Vault: </p> </blockquote> <p> </p> <blockquote> <blockquote> <p> <a class="ext-link" href="http://www.boostpro.com/vault/index.php?action=downloadfile&amp;filename=creasing.zip&amp;directory=Algorithms"><span class="icon">​</span>http://www.boostpro.com/vault/index.php?action=downloadfile&amp;filename=creasing.zip&amp;directory=Algorithms</a> </p> </blockquote> </blockquote> <p> However, it was since discovered that: </p> <blockquote> <p> boost/detail/algorithm.hpp </p> </blockquote> <p> has an implementation of is_sorted that more than meets the requirements of the original proposal. </p> <p> Further, it was discovered that the current N3000 draft of C++0x (nay, C++1x) has is_sorted and is_sorted_until algorithms that also meet/exceed the original proposal requirements: </p> <blockquote> <p> <a class="ext-link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n3000.pdf"><span class="icon">​</span>http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n3000.pdf</a> </p> </blockquote> <p> So, this ticket requests: </p> <p> 1) Promote is_sorted from boost/detail/algorithm.hpp to boost/algorithm/sorted.hpp such that it is implied "Yes, you can use this template. It is maintained and not just an implementation detail subject to change/disappearance." </p> <p> 2) Better yet, update the implementation to include is_sorted_until proposed in C++1x N3000. </p> <p> It'll be a long time until before compilers widely support C++1x. Having a boost-equivalent implementation until then would be great. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3873 Trac 1.4.3 giecrilj@… Sun, 07 Mar 2010 18:21:44 GMT component, severity changed; cc, owner, version set https://svn.boost.org/trac10/ticket/3873#comment:1 https://svn.boost.org/trac10/ticket/3873#comment:1 <ul> <li><strong>cc</strong> <span class="trac-author">giecrilj@…</span> added </li> <li><strong>owner</strong> set to <span class="trac-author">John Maddock</span> </li> <li><strong>version</strong> → <span class="trac-field-new">Boost Development Trunk</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">TR1</span> </li> <li><strong>severity</strong> <span class="trac-field-old">Not Applicable</span> → <span class="trac-field-new">Problem</span> </li> </ul> <p> This thing should go to TR1 and it is absolutely necessary. </p> <h2 class="section" id="Reasons">Reasons</h2> <div class="wiki-code"><div class="document"> <dl class="docutils"> <dt>Authority</dt> <dd>It is considered imporant enough to be included in the standard.</dd> <dt>Completeness</dt> <dd>A library that contains algorithms that depend on the data being ordered but does not provide an explicit concept of being ordered is incomplete.</dd> <dt>Use case</dt> <dd>For example, to be able to throw when a precomputed (tainted) data source is not ordered as expected.</dd> </dl> </div> </div><h2 class="section" id="Remarks">Remarks</h2> <div class="wiki-code"><div class="document"> <table border="1" class="docutils"> <colgroup> <col width="21%" /> <col width="19%" /> <col width="60%" /> </colgroup> <thead valign="bottom"> <tr><th class="head">instead of</th> <th class="head">better name</th> <th class="head">reason</th> </tr> </thead> <tbody valign="top"> <tr><td><tt class="docutils literal">is_sorted</tt></td> <td><tt class="docutils literal">is_ordered</tt></td> <td>sorting and ordering are different concepts</td> </tr> <tr><td><tt class="docutils literal">is_creasing</tt></td> <td><tt class="docutils literal">is_growing</tt></td> <td>hard to understand</td> </tr> </tbody> </table> </div> </div><h3> Aside </h3> <div style="font-family: serif; font-size: smaller"> <p>I am in the state of a double astonishment because</p> <ol><li>Nobody (including yours truly) has figured out it is missing for the latest 12 years,</li> <li>As soon as I realized it is missing, a public discussion about it starts (not initiated by yours truly).</li></ol></div> Ticket John Maddock Mon, 08 Mar 2010 10:31:56 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/3873#comment:2 https://svn.boost.org/trac10/ticket/3873#comment:2 <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">wontfix</span> </li> </ul> <p> Sorry guys, but this is emphatically not a type_trait, nor will it get added to Boost.TR1: that mirrors the already published TR which does not contain is_sorted. </p> <p> Even though such an algorithm exists as an implementation detail, promotion to full Boost status still really requires some kind of review to verify that we have the correct semantics and range of algorithms supported. </p> <p> So... I'm afraid I'm closing as won't fix.... especially as we appear not to have a maintainer for Boost.Algorithm at present :-( If I'm wrong about that, please reopen and assign to them. Otherwise you're going to have to lobby for a review - I do note that you're still in the review queue - and it shouldn't be that hard to find a review manager for this little library if you ask around. </p> <p> Regards, John. </p> Ticket ne01026@… Mon, 08 Mar 2010 13:09:08 GMT component changed https://svn.boost.org/trac10/ticket/3873#comment:3 https://svn.boost.org/trac10/ticket/3873#comment:3 <ul> <li><strong>component</strong> <span class="trac-field-old">TR1</span> → <span class="trac-field-new">graph</span> </li> </ul> <p> All right. I have done some research and can come up with the following conclusions: </p> <ol><li>The draft algorithm is <code>std::is_sorted</code> and not <code>std::tr1::is_sorted</code> so it does not belong to <strong>TR1</strong> indeed. </li><li>The Boost implementation has been grafted from HP/SGI STL; it is deficient (the draft standard algorithm is more modular) and used by the <strong>graph</strong> library only. This raises the question whether the <strong>graph</strong> package is allowed to rely on such undocumented features. </li><li>Of course, it is not a <strong>graph</strong> feature, so it cannot be provided there. </li></ol><p> All in all, a new Algorithm library is needed, or the implementation could be added to <strong>minmax</strong> because it is close enough. However, <strong>minmax</strong> cannot be chosen as a target component <em>(why?)</em> so I bring this to <strong>graph</strong> attention for the time being. </p> Ticket