From: Warren Young Date: October 10 2008 11:38pm Subject: Re: [documentation] Confusion: vector::operator[] and exceptions List-Archive: http://lists.mysql.com/plusplus/8022 Message-Id: <48EFE770.8040504@etr-usa.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit me22 wrote: > vector::operator[] does not throw exceptions > for out-of-range indexes, so I was surprised that Row does. I consider that a design error in STL. Unchecked array indexing is sooo last millennium. I stick by Row::operator[]() being implemented in terms of vector::at() under the hood. > it seems that operator[] is actually calling the vector's at. > That seems like a waste of time, since it's already checked that the > index is valid. That's true for char* indexes, but not for int. I can see changing the char* case to use vector::operator[] instead. I can't study it right now, but consider it on the wishlist for 3.0.7. > And in the case that the index *is* out of range, it > throws a custom exception, not the one from vector::at, contrary to > the documentation. Hmmm, yes, I'll have to think about this, too. I'm not sure if the exceptions need to be harmonized, or the docs need to be clarified.