Bug in STL list<> template?

Gerald Pfeifer pfeifer@dbai.tuwien.ac.at
Wed Dec 9 03:04:00 GMT 1998


On Thu, 12 Nov 1998, Gregory Bond wrote:
>   |a.size()     size_type           a.end()-a.begin()               (Note A)   |
> 
> where the notes say
> 	Those entries marked ``(Note  A)'' should have constant complexity.
> 
> In the SGI list<> template, the size() member does
>  size_type size() const {
>     size_type result = 0;
>     distance(begin(), end(), result);
>     return result;
>   }
> which is clearly linear complexity.

I believe that some time ago there was a discussion of this issue and
someone from SGI (Matt?) replied that ``should'' is not mandatory and
that for some reasons they decided to save the memory that counter 
costed.

Personally I don't like that, but apparently it's compliant with the
standard.

Gerald
-- 
Gerald Pfeifer (Jerry)      Vienna University of Technology
pfeifer@dbai.tuwien.ac.at   http://www.dbai.tuwien.ac.at/~pfeifer/




More information about the Gcc-bugs mailing list