This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: list<>.size()



> > Why is this tedious?  You do know about list<...>.empty(), don't you?
> 
> Of course I know about it. It is simple to change those, but any
> instance where they *do* wish the size, and not just to know if it's
> empty, it is a problem.

I'm sorry, but you guys signed up to be a porting company, so this is
one of the things you signed up to deal with.

> It is tedious *because* I have to do it. If I could simply recompile
> without having to change this code, my life would be a little less
> difficult.

It does not appear to be possible to make list<...>::size O(1) without
violating the requirements of some of the other STL functions.  Now it
might be possible to produce an almost-O(1) implementation, where some
lists know their size and some (like lists produced by the splice method)
don't, but that would involve changing every method that alters the list
to keep a private member with the correct value.  If you think it would
save you time, one possible approach you could take would be to alter
the list template in that way ... but then you'd have to maintain the
code yourself.




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]