Is there a time difference in accessing each char using the [] operator vs calling string's iterator? I'm very curious about the time complexity of using the [] operator, since I couldn't find it online
http://www.cplusplus.com/reference/string/string/operator[]/
I also heard that it's better to use a range based loop like
void print(const std::string &s)
{
for (char const &c: s) {
std::cout << c << ' ';
}
}
Would this perform better than using an iterator?