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

2005-11-23 Thread
The C++ standard said Container::size() should have constant complexity (ISO/IEC 14882:1998, pp. 461, Table 65), while the std::list::size() in current STL of GCC is defined as { std::distance(begin(), end()); }, whose complexiy is O(n). Is it a bug?

A bug in the current released GCC 4.0.0

2005-04-23 Thread
Hello, I casually found a bug in the current released GCC 4.0.0. However, I have located the wrong code, and it's very easy to be fixed, so it's not necessary to still submit a bug report. See the following artificial C++ code: int *x; void f() { do