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<x::sregex_token_iterator> regex_tokens;
typedef ::std::vector<regex_tokens> regex_transformed_collection;
inline regex_tokens apply_regex(regex_type const& re, std::string const& item)
{
typedef x::sregex_token_iterator sre_iter;
return boost::make_iterator_range(sre_iter(item.begin(), item.end(), re), sre_iter());
}
// usage:
std::vector<std::string> v; //vector is filled with strings of type: some_part;some_other_part
typedef regex_transformed_coll::const_iterator re_citer;
regex_transformed_collection sep_strings;
::std::transform
(
v.begin(), v.end(), ::std::back_inserter(sep_strings)
, ::std::tr1::bind(&apply_regex, sem_separated, tr1::placeholders::_1)
);
//v is in the same scope and valid
for(re_citer curr=sep_strings.begin(), end=sep_strings.end(); curr!=end; ++curr)
{
regex_tokens const& toks = *curr;
std::string source = toks.front
(); //this line is fine and returns me the first part of a string...
// all subsequent line will raise an assertion
std::string includes = *++toks.begin();
size_t sz =
toks.size();
}
Is there smth. I did not take in account? This code crashes in:
regex_token_iterator.hpp:
regex_token_iterator<BidiIter> &operator ++()
{
->>HERE>> this->fork_(); // un-share the implementation
And is caused by regex_token_iterator_impl ctor.
I know this code is not very efficient, since it iterates through the collection of strings twice instead of doing smth. within one run, but it is just an example.
Many thanks,
Ovanes