Boost logo

Boost :

From: Neal Becker (ndbecker2_at_[hidden])
Date: 2005-09-01 21:16:45


I see I can get this to work by adding an ugly const_cast. This seems to
confirm my suspicion, that the problem is caused by iterator_facade having
template <class Facade>
      static typename Facade::reference dereference(Facade const& f)
      {
          return f.dereference();
      }

IIUC the problem is the const in the above. To make my adaptor work, I did
this:
    scalar_type & dereference() const {
      return (cnt % 2 == 0) ?
const_cast<complex_type&>(*this->base_reference()).real() :
const_cast<complex_type&>(*this->base_reference()).imag();
    }

So, basically, my dereference() has to lie about being const.

Is this really correct? Is there another way to make my dereference without
this ugly cast?


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