|
Boost Users : |
From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-07-24 12:31:19
"Hickman, Greg" <greg.hickman_at_[hidden]> wrote in message
news:58F604E3D17AD4119D8600508BE32506017B6CF1_at_emss07m04.lmtas.lmco.com...
> I have a class that holds a container of pointers to polymorphic Base
> classes. I'd like clients who iterate over those Bases using a mutating
> iterator type to be able to call non-const Base class member functions
(but
> I do not want those clients to be able to replace the Base* directly).
I'd
> also like clients who iterate using a const_iterator type to be able to
call
> only const Base class member functions.
>
> In the following test code, I've attempted to use boost::iterator_adaptor
to
> create a const iterator with these properties, but the const_iterator
still
> allows calls to non-const operations. Can anyone help me see where I've
> gone wrong?
Umm, right....
> #include <boost/iterator_adaptors.hpp>
> #include <boost/utility.hpp>
> #include <iostream>
> #include <list>
>
> class Base : private boost::noncopyable {
> public:
> virtual ~Base() {}
> virtual void foo() const = 0;
here?------------------^^^^^
> };
HTH,
Dave
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