Boost C++ Libraries: Ticket #5027: Extension of Boost.Range algorithms https://svn.boost.org/trac10/ticket/5027 <p> Maybe an idea to extend Boost.Range algorithms: </p> <ul><li>copy_if </li><li>for_each_if </li><li>transform_if </li><li>contains (/contains_if, shortcut for std::find(...) != end) </li><li>all (/all_if) </li><li>none(/none_if, shortcut for std::find(...) == end)) </li><li>bsearch (Austern 13.2.1.2) </li></ul><p> Some of them are listed in STLAlgorithmExtensions. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5027 Trac 1.4.3 Steven Watanabe Sat, 01 Jan 2011 18:34:57 GMT <link>https://svn.boost.org/trac10/ticket/5027#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5027#comment:1</guid> <description> <p> I think Marshall was handling many of these. <a class="ext-link" href="http://svn.boost.org/svn/boost/sandbox/boost/algorithm/"><span class="icon">​</span>http://svn.boost.org/svn/boost/sandbox/boost/algorithm/</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Neil Groves</dc:creator> <pubDate>Mon, 03 Jan 2011 16:55:32 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5027#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5027#comment:2</guid> <description> <p> The xxx_if versions of algorithms are all redundant due to the filtered Range Adaptor. Please see the Range Adaptor documentation. The best part of the Range Adaptor design, which I believe was first brought up by Eric Niebler is that we can easily compose the filter onto any algorithm. This is a far better separation of concerns than we see in the standard C++ library where we have only the most common use-cases covered by _if suffixed functions. I believe that Thortsen Ottosens' comment that the copy_if algorithm is '... thoroughly mis-designed' is very true. The Range Adaptors are a superior alternative requiring no duplication when writing algorithms, provide superior consistency and readability. </p> <p> The functions contains, any, all, and none I have frequently wanted and it does make sense for this to be available in Boost. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Marshall Clow</dc:creator> <pubDate>Mon, 03 Jan 2011 17:14:03 GMT</pubDate> <title>owner changed https://svn.boost.org/trac10/ticket/5027#comment:3 https://svn.boost.org/trac10/ticket/5027#comment:3 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Neil Groves</span> to <span class="trac-author">Marshall Clow</span> </li> </ul> <p> I am preparing a submission for Boost.Algorithm, which will contain many of these (and an extension mechanism to make adding the rest fairly simple) </p> Ticket gast128 <gast128@…> Mon, 03 Jan 2011 18:56:19 GMT <link>https://svn.boost.org/trac10/ticket/5027#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5027#comment:4</guid> <description> <p> Ah yes I read about it but didn't think of it. It could be then: </p> <p> std::vector&lt;Base&gt; vec; std::vector&lt;Base&gt; vec2; </p> <p> boost::copy(vec | boost::adaptors::filtered(boost::bind(&amp;Base::Get, _1) == 2), std::back_inserter(vec2)); </p> <p> Traditionally it would be then: std::copy_if(vec, std::back_inserter(vec2), boost::bind(&amp;Base::Get, _1) == 2)); </p> </description> <category>Ticket</category> </item> <item> <dc:creator>gast128</dc:creator> <pubDate>Mon, 26 Mar 2012 11:40:41 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5027#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5027#comment:5</guid> <description> <p> void Test() { </p> <blockquote> <p> std::vector&lt;Person&gt; vecPersons; std::vector&lt;Person&gt; vecPersons2; </p> </blockquote> <blockquote> <p> std::copy_if(vecPersons.cbegin(), vecPersons.cend(), std::back_inserter(vecPersons2), [](const Person&amp; crPerson) -&gt; bool { </p> <blockquote> <p> return crPerson.<a class="missing wiki">GetAge</a>() == 27; </p> </blockquote> <p> }); </p> </blockquote> <blockquote> <p> auto fc = [](const Person&amp; crPerson) -&gt; bool { </p> <blockquote> <p> return crPerson.<a class="missing wiki">GetAge</a>() == 27; </p> </blockquote> <p> }; </p> </blockquote> <blockquote> <p> boost::copy(vecPersons| boost::adaptors::filtered(fc), std::back_inserter(vecPersons2)); </p> </blockquote> <p> } </p> <p> note: somehow my formatting gets lost, forgot how to fix that. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Marshall Clow</dc:creator> <pubDate>Mon, 09 Jul 2012 16:19:03 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5027#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5027#comment:6</guid> <description> <p> <code>copy_if</code>, <code>contains</code> (but named <code>any_of</code>), <code>all</code> (but named <code>all_of</code>), <code>none</code> (named <code>none_of</code>) are part of Boost.150 </p> <p> <code>for_each_if</code>, <code>transform_if</code>, and <code>bsearch</code> are not. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Neil Groves</dc:creator> <pubDate>Thu, 05 Jun 2014 18:20:27 GMT</pubDate> <title>component changed https://svn.boost.org/trac10/ticket/5027#comment:7 https://svn.boost.org/trac10/ticket/5027#comment:7 <ul> <li><strong>component</strong> <span class="trac-field-old">range</span> → <span class="trac-field-new">algorithm</span> </li> </ul> <p> I've just moved this to the Algorithm component, since the comments above indicate that Marshal shall be implementing these in Boost.Algorithm. </p> <p> I'm happy to assist if desired. </p> Ticket