Boost C++ Libraries: Ticket #2777: find_format_all calls formatter with invalid match https://svn.boost.org/trac10/ticket/2777 <p> find_format_all() calls the formatter with an invalid match when the end of the input is reached. </p> <p> Example: </p> <pre class="wiki">// A Boost.StringAlgo Formatter expecting // to be called with matches to the regex: // (\d+\.)(\d+) struct NextVersionNumber { template&lt;class RegexMatchT&gt; std::string operator()(const RegexMatchT&amp; M)const { // Without this check, we end up with // a bad_lexical_cast exception, // because operator() ends up being called twice: // First with a good match, and then with an emtpy one if (!Match){ return ""; } using boost::lexical_cast; return M.match_results()[1] + lexical_cast&lt;std::string&gt;( lexical_cast&lt;unsigned int&gt;(M.match_results()[2]) + 1 ); } }; int main() { namespace bsa = boost::algorithm; const std::string s("version is 1.0"); // Outputs: // version is: 1.1 std::cout &lt;&lt; bsa::find_format_all_copy( s, bsa::regex_finder(boost::regex("(\\d+\\.)(\\d+)")), NextVersionNumber() ); return 0; } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2777 Trac 1.4.3 Pavol Droba Wed, 18 Feb 2009 22:19:46 GMT status changed https://svn.boost.org/trac10/ticket/2777#comment:1 https://svn.boost.org/trac10/ticket/2777#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket Steven Watanabe Wed, 09 Jun 2010 23:04:29 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/2777#comment:2 https://svn.boost.org/trac10/ticket/2777#comment:2 <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/62695" title="Avoid calling the formatter with an invalid match. Fixes #2777">[62695]</a>) Avoid calling the formatter with an invalid match. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2777" title="#2777: Bugs: find_format_all calls formatter with invalid match (closed: fixed)">#2777</a> </p> Ticket