If I have a string passed in that has some characters at the beginning of it that each signify a type of info and I want to put it in a loop that each time strips off one more character from the beginning, does it make more sense to use "substr" or the pointer?
Code:
//Example one
void doSmth(std::string &str, int length)
{
for ( int i = 0; i < length; i++ )
{
//some code elided here
...
else doSmth( str.substr( i ), length - i );
}
}
//Example two
void doSmth(std::string &str, int length)
{
for ( int i = 0; i < length; i++ )
{
//some code elided here
...
else doSmth( *(++str), length - i );
}
}