Namespaces
Variants
Actions

Talk:cpp/container/map/find

From cppreference.com
< Talk:cpp‎ | container‎ | map

For examples it would be better to omit the auto keyword so that readers see the type, even if it is long and unwieldy. 217.229.134.47 09:17, 21 September 2015 (PDT)

[edit] Use cend() instead of end()

The STD::map find() function returns a const_iterator, but the std::map end() function returns an iterator. Wouldn't it be better to compare like types and use cend(), which returns a const_iterator, rather than end()?

LittleDorrit (talk) 11:49, 10 January 2017 (PST)

both .find() and .end() in the example return non-const map::iterators. Had the map been declared const, both .find() and .end() would return map::const_iterators: no mismatch. --Cubbi (talk)