Boost logo

Boost :

From: John Torjo (john.lists_at_[hidden])
Date: 2003-07-10 12:35:24


----- Original Message -----
From: "popov" <boost_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Tuesday, July 08, 2003 8:03 PM
Subject: [boost] smart_assert and range_ template

> (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

Here I am ;-)

> 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.

I think you are right. A past the end iterator should not be
dereferenceable.
I will modify the code, and let you know.

Best,
John


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk