This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: list<>.size()
- To: briareos at lokigames dot com (Michael Vance)
- Subject: Re: list<>.size()
- From: Joe Buck <jbuck at possibly dot synopsys dot com>
- Date: Mon, 3 Apr 2000 09:04:14 -0700 (PDT)
- Cc: dan at cgsoftware dot com (Daniel Berlin), gcc at gcc dot gnu dot org
> > 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.