Boost C++ Libraries: Ticket #6683: find family of functions needs const Range1T& Input overloads https://svn.boost.org/trac10/ticket/6683 <p> It's cumbersome to have to create named temporaries when searching using these functions. I presume the reason for why Input isn't const is due to the fact that iterator_range&lt;&gt; that's returned can modify Input. In the spirit of std &amp; the rest of boost I propose an overload which returns const_iterator_range&lt;&gt;, which would provide the same functionality as iterator_range&lt;&gt; save for being able to modify the source. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6683 Trac 1.4.3 Marshall Clow Tue, 13 Mar 2012 15:07:24 GMT status changed https://svn.boost.org/trac10/ticket/6683#comment:1 https://svn.boost.org/trac10/ticket/6683#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> Ok, I'm confused here; the title says "needs const Range1 T&amp; <em>input</em> overloads", but the body talks about having an overload that <em>returns</em> a range. </p> <p> The search algorithms return a single iterator, not a range. If you look in the file boyer_moore.hpp, there are a set of calls that take ranges. I have to add those calls to the other search algorithms, but I'd appreciate it if you would tell me what you think is lacking there. </p> Ticket anonymous Tue, 13 Mar 2012 17:51:15 GMT <link>https://svn.boost.org/trac10/ticket/6683#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6683#comment:2</guid> <description> <p> Sorry. The signature for lets say find_first is: </p> <p> template&lt;typename Range1T, typename Range2T&gt; inline iterator_range&lt; BOOST_STRING_TYPENAME range_iterator&lt;Range1T&gt;::type &gt; find_first( Range1T&amp; Input, const Range2T&amp; Search ) </p> <p> As Input isn't const it's not possible to pass rvalues. Now, what I speculate is the reason for why it isn't const ( because it would be natural to assume that merely searching would not need to alter the content ), is because iterator_range&lt;&gt; in this case which is returned from the function gives the caller the opportunity to alter Input indirectly through the iterator_range. So, what I propose is something which would have the following signature instead added as an overload: </p> <p> template&lt;typename Range1T, typename Range2T&gt; inline const_iterator_range&lt; BOOST_STRING_TYPENAME const_range_iterator&lt;Range1T&gt;::type &gt; find_first( const Range1T&amp; Input, const Range2T&amp; Search ) </p> <p> const_iterator_range in this case would serve the same role that const_iterator does compared to iterator in std. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Marshall Clow</dc:creator> <pubDate>Wed, 14 Mar 2012 03:15:31 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6683#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6683#comment:3</guid> <description> <p> Ok - my bad. I thought that you were talking about the stuff I just added like <code>boyer_moore_search</code>, etc. You meant the string routines. </p> <p> So, in addition to </p> <pre class="wiki">iterator_range&lt;typename range_iterator&lt;Range1T&gt;::type&gt; find_first( Range1T&amp; Input, const Range2T&amp; Search); </pre><p> you want something like: </p> <pre class="wiki">const_iterator_range&lt;typename const_range_iterator&lt;Range1T&gt;::type&gt; find_first( const Range1T&amp; Input, const Range2T&amp; Search); </pre><p> Basically, when you pass in a constant range, you get back a constant range. is that correct? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 14 Mar 2012 08:54:17 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6683#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6683#comment:4</guid> <description> <p> Yupp, I want to be able to write for example: </p> <pre class="wiki">if( !find_first( foo.getName(), bar.getName() ).empty() ) { ... } </pre> </description> <category>Ticket</category> </item> </channel> </rss>