How does std::map provide a constant size() operation?
This is a long and twisted story. 🙂 Yes, map, set, list, etc. keep counters to supply a constant time size(). Prior to C++11, none of the containers were required to keep counters, as their size() should be constant time, but not shall be constant time. In the standard, “should” means maybe, maybe not, and … Read more