Should the complexity of std::list::size() be O(n) or O(1)?

Jonathan Wakely jwakely.gcc@gmail.com
Tue Nov 29 16:55:00 GMT 2005


On 29 Nov 2005 16:47:14 +0100, Gabriel Dos Reis <gdr@integrable-solutions.net> wrote:
> Jonathan Wakely <jwakely.gcc@gmail.com> writes:
> 
> | Sorry for going off on a tangent, but does the standard actually
> | require contiguous storage for std::string?
> 
> It does not.  But, that does not matter.  Just pretend it does and if 
> implementations don't agree you, decree they are not portable <g>.

For this case, that's exactly what I do.  It works everywhere I need it to.
 
Thanks for confirming that, Gaby & Peter, I'll continue to write code assuming it if I need to, but continue to feel dirty for doing so ;-)

jon



More information about the Libstdc++ mailing list