Namespaces
Variants
Views
Actions

Talk:cpp/container/unordered map/begin

From cppreference.com

[edit] Use of auto in the example?

The example uses auto everywhere rather than explicitly referring to the type, or instead of using a typedef for the type. Although this is a trend spreading across cppreference, I believe in this case it reduces the usefulness of the page.

Type deduction can be useful for convenience, but for a reference site it can hide the details people come to study. The general policy is to use fully qualified names where it reveals or instructs, or auto when the details are less important.

In this case, I believe the details are more important, so the actual name should be used at least once. Someone looking for examples for using the iterator will not be able to see the types involved, they will only see that everything is auto, the types are entirely deduced. The person cannot gain understanding of using the actual interfaces involved. --Bwagstaff (talk) 14:38, 27 September 2017 (PDT)

while in general you have a point, in case of container begin/cbegin, auto is the intended usage (cbegin pretty much exist for this purpose only). A comment pointing out which begin was chosen by overload resolution and therefore which iterator type was deduced for auto could be helpful, especially if the example were to actually show both overloads being called. --Cubbi (talk) 15:15, 27 September 2017 (PDT)