Say I have the following code:
std::vector<std::string> foo({"alice", "bob"});
for (const std::string &f : foo)
std::cout << f.size() << std::endl;
if I make a mistake and change f.size() to f->size(), I get the following error from GCC:
error: base operand of ‘->’ has non-pointer type ‘const string {aka const std::basic_string}
Why is the actual type const std::basic_string<char> rather than const std::basic_string<char> & (reference)?
const std::basic_string<char> &?fisn't an iterator.