The following code illustrates a problem I'm having trying to use
iterator_adaptor. Basically, I have a container of shared pointers to
mutable, and I'd like to provide a const_iterator to clients that disallows
modification of both the shared pointer as well as the pointee.
Specifically, I'd like to prevent clients from writing the two lines
preceeding the return from main below. Can anyone help?
Thanks,
Greg
#include
const_iterator;
const_iterator begin() const { return const_iterator(shapes_.begin()); } Shapes shapes_; }; int main(int argc, char* argv[]) { Picture pic; const Picture& cpic = pic; pic.shapes_.push_back(Shape_ptr(new Concrete_shape)); Picture::const_iterator i = cpic.begin(); // I'd like to prevent clients from writing... i->reset(new Concrete_shape); *i = Const_shape_ptr(new Concrete_shape); return 0; }
participants (1)
-
Hickman, Greg