Reputation: 38919
Given string foo
, when I call:
auto bar = foo.begin();
There are 2 overloads of string::begin
. One returns an string::iterator
and the other returns a string::const_iterator
. How can I know the type of bar
? Is this just based on whether foo
is const
or not?
Upvotes: 0
Views: 69
Reputation: 73366
Is this just based on whether
foo
is const or not?
Yes
auto
is meant for deducing the exact type*
How to select iterator type using auto variable? indirectly agrees with this answer.
*Taken from: How do I get a const_iterator using auto?
Upvotes: 3