Hi,
I need to iterate thru strings (For various reasons, I can’t
use string or vector<char> containers).
I found that boost::range exactly fits the bill for me. I
get all the convenience of an iterator (from as_literal.hpp).
I have a piece of code
char* char_s = "I am fine";
char *cp;
std::size_t sz = strlen(char_s);
const char*
str_end1 = str_begin( char_s ) + sz;
for (cp = str_begin(char_s); cp !=
str_end(char_s); ++cp)
cout << *cp;
I have couple of questions:
1.
In the loop, boost::range seems to be calling strlen
every iteration. This is an overhead. I was wondering if there’s a way I
can pass in the length myself so that boost::range would use it and avoid
calling strlen().
2.
If it’s not possible, is there a way for me to
use iterators (boost or non-boost) over char strings?
Thanks so much in advance for your help,
Anant