I am using gcc 4.8.1 and after hours of debugging a horrible mysterious performance issue I found out that the std::list::size
is actually implemented as a call to std::distance
.
/** Returns the number of elements in the %list. */
size_type
size() const _GLIBCXX_NOEXCEPT
{ return std::distance(begin(), end()); }
This surprised me, since the reference says that the complexity of std::list::size should be constant and the complexity of std::distance
is linear for std::list::iterator
.
I am really confused, since I think gcc has excellent support for C++11 features and I see no reason why they would not implement this one.
Is this an error in the reference or in gcc?
In the latter case:
is there any reason why such a fundamental C++11 feature would be missing for so long?
Is there a third possibility e.g.:
Could I have gcc 4.8.1 but some older version of the standard library?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…