I guess most people understand that the complexity of size()
function is not guaranteed to be constant. Though in some implementations, it is constant.
The G++ compiler is probably the most commonly used compiler. So, in G++'s implementation, what's the complexity of size()
? If it varies by different containers, what containers have linear complexity? For the most commonly used ones (such as list, vector, deque, set, & map), are they all constant?