safe container classes

Is there a well-designed stupid-programmer-proof container class library available for C++?

BACKGROUND:

OK, so I've used the STL for many years. In the STL whenever there was a design/implementation tradeoff between user safety and performance, the STL designers almost always chucked user-safety to the wind to make the STL run ever-so-slightly faster. This is not always the case -- just usually.

For example, in the implementation of the STL that comes with gnu c++ 4.3.4 calling c1.erase(i2) where c1 is a set and i2 is an iterator pointing into some OTHER set c2, results in corruption of c1 (nasty stuff). In fact, every evil thing I tried during 15 minutes of experimentation with the STL failed to produce an exception (or even a crash) and instead silently did really weird stuff.

Now, I'm not here to bash the STL, but I do believe that most developers would be better served by spending a few extra clock cycles to check inputs and throwing an exception when that input is bad. So I'm wondering if there is some other product (preferably free) where programmer safety was given a little more weight during the design process.

Thanks,
Matt Busche
closed account (zb0S216C)
C++ provides the tools but relies on the client to responsibly use those tools. Try Boost. I don't use it personally, but its size is vast and I'm sure they have containers.

Wazzak
http://www.boost.org/doc/libs/?view=category_Containers

Apparently, they see <vector> as sufficiently safe/easy, as I don't really see anything like it.
All in all, STL vectors are pretty safe. There are very few logic-wise mistakes you can make that will crash or cause weird things. If you're going to build a container for pure user-errors (typos and general stupidity), you're not doing anyone a favor.
where c1 is a set and i2 is an iterator pointing into some OTHER set c2
Yeah, don't do that stuff.
If you want those check, make a wrapper. You could make that the iterator receives the container to which belongs (you may or may not change containers).
Make sure that you don't kill the container before the iterator.
Topic archived. No new replies allowed.