Boost logo

Boost Users :

Subject: [Boost-users] Problem with iterator_facade
From: Robert Dailey (rcdailey_at_[hidden])
Date: 2008-09-16 17:21:47


Hi,

I have the following iterator_facade class:

        class PassIterator
                : public boost::iterator_facade<
                        PassIterator,
                        Pass,
                        boost::forward_traversal_tag
>
        {
        public:
                PassIterator();

                PassIterator( Effect const& effect );

        private:
                void increment();
                Pass& dereference() const;

                Pass m_pass;

                friend class boost::iterator_core_access;
        };

Note how my Pass object is stored by-value in my PassIterator class.
When I attempt to compile this class, it fails because dereference()
is const and it is trying to return a reference to a const member.
However, if I make dereference() non-const, it still fails because the
base class is calling into PassIterator::dereference() through a const
member function as well, so dereference() *must* be const in order to
be callable by boost.

How can I overcome this issue? const_cast? mutable? Thanks.


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