
I'm experimenting with boost::split_regex and ran into an issue. The first three examples (results1, results2, results3) compile and work as expected. The last one (results4) does not compile. Here's the code I'm using: std::string str1("hello abc-ABC-aBc goodbye"); static const boost::regex re("-ABC-"); std::vector<boost::iterator_range<std::string::iterator> > results1; boost::ifind_all( results1, str1, "abc" ); std::vector<boost::iterator_range<std::string::iterator> > results2; boost::split(results2, str1, boost::is_any_of("-")); std::vector<std::string> results3; boost::split_regex(results3, str1, re); std::vector<boost::iterator_range<std::string::iterator> > results4; // compile error on this line: boost::split_regex(results4, str1, re); I've read the documents here: http://www.boost.org/doc/libs/1_48_0/doc/html/boost/algorithm/split_regex.ht... and I believe my usage of split_regex is correct? It compiles and works with std::string (results3) but not with boost::iterator_range. The compiler error is long and verbose, so I'm hesitant to post it here. I was hoping that someone could look at the usage example I provided and see how I'm doing it wrong. I prefer iterator_range as it does not make a copy. Thanks for any advice! Brad

I think I've got it now... re-reading the docs, this approach seems to work: std::vector<boost::iterator_range<std::string::iterator> > results4; boost::split_regex(results4, boost::make_iterator_range(str1.begin(), str1.end()), re); On Jan 18, 10:39 am, Brad Tilley <kj4...@gmail.com> wrote:
I'm experimenting with boost::split_regex and ran into an issue. The first three examples (results1, results2, results3) compile and work as expected. The last one (results4) does not compile. Here's the code I'm using:
std::string str1("hello abc-ABC-aBc goodbye"); static const boost::regex re("-ABC-");
std::vector<boost::iterator_range<std::string::iterator> > results1; boost::ifind_all( results1, str1, "abc" );
std::vector<boost::iterator_range<std::string::iterator> > results2; boost::split(results2, str1, boost::is_any_of("-"));
std::vector<std::string> results3; boost::split_regex(results3, str1, re);
std::vector<boost::iterator_range<std::string::iterator> > results4; // compile error on this line: boost::split_regex(results4, str1, re);
I've read the documents here:http://www.boost.org/doc/libs/1_48_0/doc/html/boost/algorithm/split_r... and I believe my usage of split_regex is correct? It compiles and works with std::string (results3) but not with boost::iterator_range. The compiler error is long and verbose, so I'm hesitant to post it here. I was hoping that someone could look at the usage example I provided and see how I'm doing it wrong. I prefer iterator_range as it does not make a copy.
Thanks for any advice!
Brad
participants (1)
-
Brad Tilley