Andre Poenitz wrote: > On Tue, Nov 04, 2003 at 12:19:25PM +0000, Angus Leeming wrote: >> I have a container that currently allows the user to alter the Node >> container. I want to allow the user to be able to alter the Node >> contents but to not be able to insert, erase Nodes from the vector. >> >> What's the best way to proceed?
> /// The element list is immutable. > //std::vector<Element> const & elements() const { return > elements_; } Element const & element(size_t i) const { > return elements_[i]; } Element & element(size_t i) { return > elements_[i]; } Actually, it's perfectly safe to provide iterators isn't it, so long as I don't provide access to the storage container itself? template <typename Element> class ElementList { public: typedef typename Element::size_type size_type; typedef typename std::vector<Node>::iterator node_iterator; typedef typename std::vector<Node>::const_iterator const_node_iterator; typedef typename std::vector<Element>::const_iterator const_element_iterator; ElementList(std::vector<Node> const & nodes, std::vector<Element> const & elements); size_type nnodes() const { return nodes_.size(); } size_type nelements() const { return elements_.size(); } node_iterator begin_nodes() { return nodes_.begin(); } node_iterator end_nodes() { return nodes_.end(); } const_node_iterator begin_nodes() const { return nodes_.begin(); } const_node_iterator end_nodes() const { return nodes_.end(); } const_element_iterator begin_elements() const { return elements_.begin(); } const_element_iterator end_elements() const { return elements_.end(); } private: std::vector<Nodes> nodes_; std::vector<Elements> elements_; -- Angus