Boost logo

Boost Users :

From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2007-10-19 02:42:03


Well, sorry I did not check mails before. Actually, I should have thought
about it, that token_iterator applies a transformation on each iteration.
Many thanks. It was already late in the night, when I faced this. Sorry for
disturbing your sister's wedding. Hope you will enjoy it! Best wishes to
your sister and her husband!

With Kind Regards,
Ovanes

On 10/18/07, Eric Niebler <eric_at_[hidden]> wrote:
>
> Eric Niebler wrote:
> > Eric Niebler wrote:
> >> Ovanes Markarian wrote:
> >>> Hello Eric,
> >>>
> >>> sorry for bothering. I use xpressive in the following context:
> >> <snip>
> >>
> >> I can't get your code to compile. Please send a minimal and complete
> >> source file that demonstrates the problem.
> >
> > After fiddling with your code a bit, I got it to compile, but I'm not
> > seeing any assertions, exceptions or crashes. What version are you
> using?
>
> Me again. I realized I wasn't seeing the problem because I hadn't put
> any strings in the vector over which you were iterating. When I do, I
> can reproduce the assert. This is not a bug in xpressive, it is a bug in
> your code. The problem is here:
>
> std::tr1::bind(&apply_regex, sem_separated, td::tr1::placeholders::_1)
>
> In this call to bind, you pass sem_separated to bind() *by value*. You
> return a regex_token_iterator, which holds a reference to the
> (temporary) regex object. When the temporary regex object goes away, the
> regex_token_iterators are left holding dangling references.
>
> The lifetime of a regex_token_iterator cannot exceed the lifetime of the
> regex it holds.
>
> If you change the code to ...
>
> std::tr1::bind(&apply_regex, std::tr1::ref(sem_separated),
> td::tr1::placeholders::_1)
>
> ... it works just fine.
>
> HTH,
>
> --
> Eric Niebler
> Boost Consulting
> www.boost-consulting.com
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



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