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

Gabriel Dos Reis gdr@integrable-solutions.net
Tue Nov 29 17:43:00 GMT 2005


Jonathan Wakely <jwakely.gcc@gmail.com> writes:

| 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 ;-) 

basic_string is such, hmm, "interesting" data structure that you
should not feel dirty :-) :-)

-- Gaby



More information about the Libstdc++ mailing list