Hello Eric,
sorry for bothering. I use xpressive in the following context:
typedef x::sregex regex_type;
const regex_type non_semicolon = ~x::as_xpr(';');
const regex_type sem_separated = *non_semicolon;
typedef boost::iterator_range
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. Note: I'm currently in New York for my sister's wedding. I may not get to this until next week. -- Eric Niebler Boost Consulting www.boost-consulting.com
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?
Below is the full source. I had to comment out the line to toks.size()
-- iterator_range::size() requires random access iterators, and
regex_token_iterator is not random access. I can't imagine how this
compiles for you.
Also, your example is highly suspect at this line:
std::string includes = *++toks.begin();
iterator_range::begin() returns an iterator *by value*. The ++ is
mutating the copy, not the iterator stored in the range. Did you mean to
do that?
#include <string>
#include <iostream>
#include
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
participants (2)
-
Eric Niebler
-
Ovanes Markarian