List:MySQL++« Previous MessageNext Message »
From:Warren Young Date:October 10 2008 11:38pm
Subject:Re: [documentation] Confusion: vector::operator[] and exceptions
View as plain text  
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.
Thread
[documentation] Confusion: vector::operator[] and exceptionsme2211 Oct
  • Re: [documentation] Confusion: vector::operator[] and exceptionsWarren Young11 Oct
    • Re: [documentation] Confusion: vector::operator[] and exceptionsRick Gutleber13 Oct
  • Re: [documentation] Confusion: vector::operator[] and exceptionsWarren Young8 Nov