|
Boost : |
From: popov (boost_at_[hidden])
Date: 2003-07-08 12:03:10
(not sure it's the right place to post this, but it seems smart_assert is
(or will) be part of boost, and I can't get the author email addresses. The
article is:
http://www.cuj.com/documents/s=8464/cujcexp0308alexandr/)
Here's an excerpt of some code:
template< class iterator_type>
inline client_ostream_type & operator<<( client_ostream_type & out, const
printer_range_t< iterator_type> &val) {
out << "Range= [" << &*(val.m_first) << "," << &*( val.m_last) << "); "
<< "Values= [";
val.m_first and val.m_last are STL iterators.
The problem is with *(val.m_last) (or *(val.m_first)): if val.m_last is the
end iterator of a container, can we safely dereference it as it is done ?
What the standard is saying about that one ?
The code works properly with Microsoft STL, but fails using STLPort in debug
mode: in this latter case, the program asserts and stops at:
reference operator*() const {
_STLP_DEBUG_CHECK(_Dereferenceable(*this))
return *this->_M_iterator;
}
and STLPort outputs in the ouptut window: "STL assertion failure :
_Dereferenceable(*this)"
So, for STLPort, an iterator pointing to the end of a container can't be
dereferenced. That seems judicious to me, but is it in accordance with the
standard ?
If it's the case, then there is a problem in the smart_assert code.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk