
2 Sep
2005
2 Sep
'05
2:16 a.m.
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?