[Bug libstdc++/49561] [C++0x] std::list::size complexity

blelbach at cct dot lsu.edu gcc-bugzilla@gcc.gnu.org
Tue Sep 20 00:59:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49561

Bryce Lelbach (wash) <blelbach at cct dot lsu.edu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |blelbach at cct dot lsu.edu

--- Comment #2 from Bryce Lelbach (wash) <blelbach at cct dot lsu.edu> 2011-09-20 00:15:40 UTC ---
(In reply to comment #1)
> (In reply to comment #0)
> > I realized that the complexity of std::list::size() is O(n), not O(1).
> > 
> > This does not conform to standard. The standard states that size() function is
> > in constant time for alls containers. 
> 
> No, the current standard does not.
> 
> The C++0x draft does, but it's not yet a standard, and parts of it are not yet
> implemented.

The current standard is now C++11. 23.2.1, Table 96 explicitly states that the
size() method of Containers must execute in constant time.

Can this bug please be changed to confirmed? As of today (r178989),
std::list<>::size() is still O(N).



More information about the Gcc-bugs mailing list