News for hackers. Stuff that matters.
Re:In C++, is empty() faster than comparing the size with zero? by tialaramex on Thursday October 28, 2021 @04:34PM (#29031551)
> What does this mean for implementations that want to have these properties but have internal structures that make this inherently difficult?

Such implementations are de facto forbidden in the STL.

Although its containers have vague names like "forward_list" today the C++ STL's containers are in practice very specific data structures that have the specified properties because other data structures would miss one or more of the requirements.

This suits "stability at all costs" C++ programmers fine. Better that every C++ program is 10% slower than that their buggy library from 1995 has to be fixed to actually do what the standard says rather than whatever worked in 1995.

If you care about this but you like C++ you just don't use the STL. Third parties are free to make containers that use data structures that aren't old enough to stand for President of the United States of America, some of them aren't even old enough to legally drive in the United States of America.

There are no comments on this comment yet.