Reputation: 403
I have a nonconst string,when dereferencing its string iterator,i have found debug information show it had a type of const char reference.Why this happen?
string str{ "Hello,world" };
for (auto it = str.begin(); it != str.end(); ++it)
{
*it = toupper(*it);
cout << *it;
}
Using Visual studio 2015.
Upvotes: 0
Views: 73
Reputation: 141554
If it yielded a const char reference then the code *it = toupper(*it);
would fail to compile, since you cannot assign to a const
.
Perhaps the debug information is wrong, or you misinterpret the debug information.
Upvotes: 4