Recently, I came across a very interesting inconsistency when using libxml ++ (C ++ shells for libxml2).
The library returns node lists using the default STL list container ( std::list<xmlpp::Node*>). Since it is installed from repositories by default, it seems to be built in C ++ 03 mode (but I am working with C ++ 11).
It should be noted here that C ++ 11 has changed the way it works std::list::size().
In C ++ 03, it was O (n), each time calling std::distance(begin(), end())- and now it returns a pre-computed value.
Here is the code:
size_type
size() const _GLIBCXX_NOEXCEPT
{
#ifdef __GXX_EXPERIMENTAL_CXX0X__
return this->_M_impl._M_size;
#else
return std::distance(begin(), end());
#endif
}
, size() . , 140734320138496, : .
, std::distance (list.begin(), list.end()) .
, GCC/libstd++ , GCC?