Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-05-21 10:47:49

"Reece Dunn" <msclrhd_at_[hidden]> writes:

> I reported that VC7 uses the correct implementation of
> reverse_iterator, and that this can be detected via
> BOOST_NO_STD_ITERATOR. Although this compiles, you cannot use reverse
> iterators.

Just use boost::reverse_iterator instead. It works better anyway.

> The problem is that the iterator is of the form (const) T *, and this
> fails because there is not a correct implementation of iterator_traits
> (due to a lack of partial template specialization) that *is* detected

Just use boost::detail::iterator_traits instead (from
boost/detail/iterator.hpp); it works better anyway.

> The solution would therefore be to - in this case - provide an
> iterator wrapper around a standard pointer so it has the correct
> Iter::value_type, etc definitions.


> Is there an iterator_adaptor that provides this within boost? If
> not, should there be one? I am looking into this and will commit the
> solution to my iterator_adaptor-style implementation
> (sandbox/boost/fixed_string/detail/basic_string_impl.hpp).

Sounds like a hard way to go, but it's easy to build.

// untested
template <class T>
struct non_pointer_iterator
  : iterator_adaptor<non_pointer_iterator<T>, T>
    typedef iterator_adaptor<non_pointer_iterator<T>, T> super;
    non_pointer_iterator() {}
    non_pointer_iterator(T x) : super(x) {}

    template <class U>
        non_pointer_iterator<U> const& other
      , typename boost::enable_if<
          , char
>::type = 0
      : super_t(other.base()) {}

Dave Abrahams
Boost Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at