Boost logo

Boost Users :

From: Eric Niebler (eric_at_[hidden])
Date: 2008-06-04 23:21:53


Jesse Williamson wrote:
> Hi, folks!
>
> This program suprises me by causing a runtime assertion:
>
> =====
> #include <string>
> #include <boost/xpressive/xpressive.hpp>
>
> using namespace boost::xpressive;
>
> int main()
> {
> std::string x("a\tb\tc");
>
> sregex_token_iterator cur(x.begin(), x.end(), as_xpr("\t"), -1),
> end;
> for(; cur != end; ++cur)
> ;
> }
> =====
<snip>

Interesting. Currently the regex iterators hold a (bare) pointer to the
regex to be used. If you pass in a temporary regex, it'll obviously not
live long enough. It wouldn't be hard to make the regex iterators hold a
reference count to the regex impl, which would make your code work. The
down-side would be that copying regex iterators (a common operation?)
would be more expensive.

Thanks for the report. While I ruminate about it, could you could file a
bug on our bug tracker? (Click the "New Ticket" link at
http://svn.boost.org/trac/boost/.) Thanks.

-- 
Eric Niebler
BoostPro Computing
http://www.boostpro.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net