Once upon a time, size() wasn't required to be constant-time. This showed up in some standard library implementations of std::list::size which actually did count all the things.
The painful ABI break at C++11 is a big part of why implementors were so opposed to allowing another ABI break in C++20.