Proxied containers and STL

One of the recent posts became the topic of my current exercise. I am trying to write a vector wrapper that behaves like reference to vector. The original vector holds pointers of a given type. The idea is to allow something similar to up-casting the wrapper, making it possible to create other wrappers to the same vector that pretend that they contain pointers to the base type instead of the derived type.

So it must be used like this:
1
2
3
4
5
vector<Derived *> vec(100);
VectorRef<Derived> vrefD(vec);
// cheap constructor that only stores a reference to the vector
VectorRef<Base> vrefB(vrefD); // copies the reference
// now the original vector can be accessed through both verfD and vrefB 

All in all, it appears that I will need to return a proxy object from the [] operator. Will this non-conformance preclude all use of this container with STL algorithms or there is some grace for it? Is there any mention in the standard, regarding the way in which a proxied container should be implemented? (How to define the member typenames, etc.)

Thanks and regards
Topic archived. No new replies allowed.