Boost logo

Boost Users :

From: Eric Niebler (eric_at_[hidden])
Date: 2005-03-11 15:46:57


Michael W. Daniels wrote:
> On Fri, Mar 11, 2005 at 10:32:18AM -0800, Eric Niebler wrote:
>
>>I don't see where hat_iterator and hat_const_iterator are defined.
>>Please send a *complete* example.
>
>
> They should have been in the third attached file ("hat_iterator.hpp").
>
> Mike Daniels

Oops, my bad! My email client was hiding it from me, but I see it now.
OK, the problem is fairly obvious.

   template <class T, class A>
   class hat_const_iterator {
   private:
     typedef hat_const_iterator<T, A> iterator;

   public:
     typedef std::random_access_iterator_tag iterator_category;
     typedef T value_type;
     typedef typename A::pointer pointer;
     typedef typename A::reference reference;
//-------------------^^^^^^^^^^^^ oops!

...

     const_reference operator*() const {
//--^^^^^^^^^^^^^^^
       return _hat->_top_array[_pos >> _hat->_power][_pos & _hat->_mask];
     }

For hat_const_iterator, the nested "reference" typedef is non-const, and
operator* is returning a const reference. The nested reference type
should be:

     typedef typename A::const_reference reference;

HTH!

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net