c++ - How does the Compiler Know Whether to Call the const Overload? -


given string foo, when call:

auto bar = foo.begin(); 

there 2 overloads of string::begin. 1 returns string::iterator , other returns string::const_iterator. how can know type of bar? based on whether foo const or not?

is based on whether foo const or not?

yes

auto meant deducing exact type*


how select iterator type using auto variable? indirectly agrees answer.

*taken from: how const_iterator using auto?


Popular posts from this blog

node.js - How do I prevent MongoDB replica set from querying the primary? -

c# - Randomly pick a specific int from a 2D Array -

php - Angularjs http.delete is not working after deploying project on server -